Created
August 30, 2015 15:00
-
-
Save lena3rika/df7ca76fe0e28343d6a2 to your computer and use it in GitHub Desktop.
This file contains 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