diff options
author | chai <chaifix@163.com> | 2021-01-25 14:28:30 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-01-25 14:28:30 +0800 |
commit | 6eb915c129fc90c6f4c82ae097dd6ffad5239efc (patch) | |
tree | 7dd2be50edf41f36b60fac84696e731c13afe617 /Client/Assets/Scripts/FMOD/XFmodUIEvent.cs |
+scripts
Diffstat (limited to 'Client/Assets/Scripts/FMOD/XFmodUIEvent.cs')
-rw-r--r-- | Client/Assets/Scripts/FMOD/XFmodUIEvent.cs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/Client/Assets/Scripts/FMOD/XFmodUIEvent.cs b/Client/Assets/Scripts/FMOD/XFmodUIEvent.cs new file mode 100644 index 00000000..984a6ee2 --- /dev/null +++ b/Client/Assets/Scripts/FMOD/XFmodUIEvent.cs @@ -0,0 +1,46 @@ +using UnityEngine;
+using System.Collections;
+
+public class XFmodUIEvent : MonoBehaviour {
+
+ static private GameObject _ui_audio = null;
+
+ public string Name = "";
+ public float Delay = 0;
+ private float _start_time;
+ void Start () {
+ if (_ui_audio == null)
+ {
+ if (GameObject.Find("UIRoot") != null)
+ _ui_audio = GameObject.Find("UIRoot").gameObject;
+ else
+ _ui_audio = GameObject.Find("UIRoot(Clone)").gameObject;
+ }
+ _start_time = UnityEngine.Time.time;
+ }
+
+ void FixedUpdate () {
+
+ if (UnityEngine.Time.time - _start_time > Delay)
+ {
+ XFmod iFmod;
+ if (_ui_audio != null)
+ {
+ iFmod = GetFmodComponent(_ui_audio);
+ iFmod.PlayOneShot("event:/" + Name, Vector3.zero);
+ }
+
+ Destroy(this);
+ }
+ }
+
+ public XFmod GetFmodComponent(GameObject go)
+ {
+ XFmod iFmod = go.GetComponent<XFmod>();
+
+ if (iFmod == null)
+ iFmod = go.AddComponent<XFmod>();
+
+ return iFmod;
+ }
+}
|