/**************************** summary: ****************************/ using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class AnchorBtnItem : MonoBehaviour,EventObserver { private Toggle m_Toggle; private Image m_Image; public Text m_Text; private GameObject m_AnchorObj; private Anchor m_Anchor; public GameObject AnchorObj { get { return m_AnchorObj; } set { m_AnchorObj = value; } } public Anchor Anchor { get { return m_Anchor; } set { m_Anchor = value; } } public void HandleEvent(EventData resp) { } private void Start() { EventManager.Instance.Register(this, EventID.EVENT_3); m_Toggle = GetComponent(); // m_Image = transform.Find("Image").GetComponent(); m_Text = transform.Find("Name").GetComponent(); m_Text.text = Anchor.pictureName; m_Toggle.onValueChanged.AddListener((state) => { if (state) { EventData1 data1 = new EventData1(EventID.EVENT_3, AnchorObj); data1.Send(); } }); } public void SetData(GameObject anchorObj ,Anchor anchor) { AnchorObj = anchorObj; Anchor = anchor; } }