| | 1 | | using UnityEngine; |
| | 2 | | using UnityEngine.EventSystems; |
| | 3 | |
|
| | 4 | | public class UIHoverObjectToggler : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler |
| | 5 | | { |
| | 6 | | public GameObject[] targetObjects; |
| | 7 | |
|
| 0 | 8 | | public void OnPointerEnter(PointerEventData eventData) { SetObjectsActiveState(true); } |
| | 9 | |
|
| 356 | 10 | | public void OnPointerExit(PointerEventData eventData) { SetObjectsActiveState(false); } |
| | 11 | |
|
| 356 | 12 | | void OnDisable() { OnPointerExit(null); } |
| | 13 | |
|
| | 14 | | void SetObjectsActiveState(bool newState) |
| | 15 | | { |
| 712 | 16 | | for (int i = 0; i < targetObjects.Length; i++) |
| | 17 | | { |
| 178 | 18 | | targetObjects[i].SetActive(newState); |
| | 19 | | } |
| 178 | 20 | | } |
| | 21 | | } |