ButtonSound: make your button play the click sound

This commit is contained in:
alexiscatnip
2022-02-06 13:01:55 +08:00
parent e27529651d
commit f4709ff464
2 changed files with 50 additions and 0 deletions
+39
View File
@@ -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);
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f1c31a79c3a650b4188b15f08d11da71
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: