using UnityEngine; using UnityEngine.UI; using TMPro; using UnityEngine.EventSystems; namespace SuperTreeView { public class ItemPrefab2 : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler { public Button mClickBtn; public TextMeshProUGUI TextName; public TextMeshProUGUI TextHover; public TextMeshProUGUI TextSelect; public GameObject TextLock; public TextMeshProUGUI TextHoverLock; string mData = ""; public string Data { get { return mData; } set { mData = value; } } void Start() { mClickBtn.interactable = true; mClickBtn.onClick.AddListener(OnItemClicked); } void OnItemClicked() { TreeViewItem item = GetComponent(); item.RaiseCustomEvent(CustomEvent.ItemClicked, mData); } public void SetItemInfo(string labelTxt, string data) { TextName.text = labelTxt; TextHover.text = labelTxt; TextSelect.text = labelTxt; //TextLock.text = labelTxt; TextHoverLock.text = labelTxt; mData = data; } public void OnPointerExit(PointerEventData eventData) { TextHover.gameObject.SetActive(false); } public void OnPointerEnter(PointerEventData eventData) { TextHover.gameObject.SetActive(true); } public bool IsSelected { get { return TextSelect.gameObject.activeSelf; } set { TextSelect.gameObject.SetActive(value); } } public void LockClick() { if (TextHover.gameObject.activeSelf || TextSelect.gameObject.activeSelf) { TextHoverLock.gameObject.SetActive(true); } else { TextLock.gameObject.SetActive(true); } mClickBtn.interactable = false; } public void UnlockClick() { TextLock.gameObject.SetActive(false); TextHoverLock.gameObject.SetActive(false); mClickBtn.interactable = true; } } }