|
| 1 | +using System.Collections; |
| 2 | +using System.Collections.Generic; |
| 3 | +using UnityEngine; |
| 4 | +using UnityEngine.UI; |
| 5 | +using UnityEngine.EventSystems; |
| 6 | +using UnityEngine.Events; |
| 7 | + |
| 8 | +public class AnimationAudioHelper : MonoBehaviour |
| 9 | +{ |
| 10 | + [System.Serializable] |
| 11 | + public class MyEvent:UnityEvent<int> {} |
| 12 | + |
| 13 | + public MyEvent onClick; |
| 14 | + public GameObject[] gameObjectsToFlip; |
| 15 | + public Selectable[] selectables; |
| 16 | + |
| 17 | + public void PlayClip(AudioClip clip) |
| 18 | + { |
| 19 | + GameManager.GM.PlayClip(clip, .5f); |
| 20 | + //AudioSource.PlayClipAtPoint(clip, GameManager.GM.ears.transform.position, 0.5f); |
| 21 | + |
| 22 | + } |
| 23 | + |
| 24 | + public void DisableGO(int which) |
| 25 | + { |
| 26 | + |
| 27 | + gameObjectsToFlip[which].SetActive(false); |
| 28 | + } |
| 29 | + public void EnableGO(int which) |
| 30 | + { |
| 31 | + |
| 32 | + gameObjectsToFlip[which].SetActive(true); |
| 33 | + } |
| 34 | + |
| 35 | + public void SelectThis(int which) |
| 36 | + { |
| 37 | + EventSystem.current.SetSelectedGameObject(selectables[which].gameObject); |
| 38 | + selectables[which].OnSelect(null); |
| 39 | + |
| 40 | + } |
| 41 | + |
| 42 | + public void ChangeGameState(int i){ |
| 43 | + GameManager.GM.SetGameState(i); |
| 44 | + } |
| 45 | + |
| 46 | + //using this at the end of an animation, after interactable is turned back on. |
| 47 | + //allows me to set the selected button from another button. |
| 48 | + public void UpdateSelected() |
| 49 | + { |
| 50 | + EventSystem.current.currentSelectedGameObject.GetComponent<Selectable>().OnSelect(null); |
| 51 | + } |
| 52 | + public void zOnClick() |
| 53 | + { |
| 54 | + onClick.Invoke(1); |
| 55 | + } |
| 56 | + |
| 57 | +} |
0 commit comments