备份CatanBuilding瘦身独立工程
This commit is contained in:
30
Assets/Scripts/UI/UIButtonSound.cs
Normal file
30
Assets/Scripts/UI/UIButtonSound.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Game;
|
||||
using asap.core;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
[RequireComponent(typeof(Button))]
|
||||
[AddComponentMenu("UGUI/UI/UIButtonSound")]
|
||||
public class UIButtonSound : MonoBehaviour
|
||||
{
|
||||
public AssetReferenceT<AudioClip> assetReference;
|
||||
public float startTimer = 0f;
|
||||
void Awake()
|
||||
{
|
||||
var btn = gameObject.GetComponent<Button>();
|
||||
|
||||
if (null != btn)
|
||||
{
|
||||
btn.onClick.AddListener(OnClick);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnClick()
|
||||
{
|
||||
if (assetReference != null && assetReference.RuntimeKeyIsValid())
|
||||
{
|
||||
GContext.Publish(new AssetReferenceAudioClip(assetReference, time: startTimer));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user