i did a dropdown menu from a youtube tutorial but she shows OnPointerEnter and OnPointerExit. i did one OnPointerClick for open but the function allows once. i want to do twice. when i click it will open, when i click again it will close. how can i do it??
The Script:
using UnityEngine;
using UnityEngine.EventSystems;
using System.Collections;
public class DropDown : MonoBehaviour, IPointerClickHandler, IPointerExitHandler{
public RectTransform container;
public bool isOpen;
// Use this for initialization
void Start () {
container = transform.FindChild ("Container").GetComponent<RectTransform> ();
isOpen = false;
}
// Update is called once per frame
void Update () {
Vector3 scale = container.localScale;
scale.y = Mathf.Lerp (scale.y, isOpen ? 1 : 0, Time.deltaTime * 12);
container.localScale = scale;
}
public void OnPointerClick(PointerEventData eventData)
{
isOpen = true;
}
public void OnPointerExit(PointerEventData eventData)
{
isOpen = false;
}
}