using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; public class BeginToggle : MonoBehaviour,IPointerClickHandler { private VideoPanel videoPanel; // Use this for initialization void Start () { videoPanel = transform.parent.parent.GetComponent(); } // Update is called once per frame void Update () { } public void OnPointerClick(PointerEventData eventData) { var isOn = GetComponent().isOn; if (isOn) { videoPanel.Play(); } else { videoPanel.Pause(); } } }