-
-
Save jcowen-Berklee/59e23a33febe522dfc74 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| using System.Collections; | |
| using UnityEngine.EventSystems; | |
| using UnityEngine.UI; | |
| public class Dropdown : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler | |
| { | |
| public RectTransform container; | |
| public bool isOpen; | |
| public Text mainText; | |
| public Image image { get { return GetComponent<Image>(); } } | |
| void Start() | |
| { | |
| container = transform.FindChild("Container").GetComponent<RectTransform>(); | |
| isOpen = false; | |
| } | |
| public void Update() | |
| { | |
| Vector3 scale = container.localScale; | |
| scale.y = Mathf.Lerp(scale.y, isOpen ? 1 : 0, Time.deltaTime * 10); | |
| container.localScale = scale; | |
| } | |
| public void OnPointerEnter(PointerEventData eventData) | |
| { | |
| isOpen = true; | |
| } | |
| public void OnPointerExit(PointerEventData eventData) | |
| { | |
| isOpen = false; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment