mirror of
https://github.com/RaindropViewer/RaindropViewer.git
synced 2026-07-27 22:11:39 +00:00
ButtonSound: make your button play the click sound
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Lean.Gui;
|
||||
using Raindrop;
|
||||
using Raindrop.ServiceLocator;
|
||||
using UnityEngine;
|
||||
|
||||
public class ButtonSound : MonoBehaviour
|
||||
{
|
||||
|
||||
public RaindropInstance Instance => ServiceLocator.Instance.Get<RaindropInstance>();
|
||||
|
||||
private LeanButton btn;
|
||||
void Awake()
|
||||
{
|
||||
try
|
||||
{
|
||||
btn = this.GetComponent<LeanButton>();
|
||||
|
||||
if (btn)
|
||||
{
|
||||
this.GetComponent<LeanButton>().OnClick.AddListener(OnClick);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
OpenMetaverse.Logger.DebugLog(e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void OnClick()
|
||||
{
|
||||
if (btn.interactable)
|
||||
{
|
||||
Instance.MediaManager.PlayUISound(UISounds.Click);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f1c31a79c3a650b4188b15f08d11da71
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user