using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class SChooseItem : MonoBehaviour { /// /// 当选择场景时触发事件 /// public event Action OnSelectScene; private Text m_SceneNameT; private Image m_SceneImage; private Toggle m_Toggle; private int m_ID; private SceneValue m_SceneData; public int ID { get { return m_ID; } set { m_ID = value; } } public SceneValue SceneData { get { return m_SceneData; } set { m_SceneData = value; } } void Awake() { m_Toggle = transform.Find("Toggle").GetComponent(); m_SceneImage = transform.Find("Scene").GetComponent(); m_SceneNameT = m_Toggle.transform.Find("Label").GetComponent(); m_Toggle.onValueChanged.AddListener(OnToggleValueChanged); } private void OnToggleValueChanged(bool b) { if (OnSelectScene != null) { OnSelectScene(m_SceneData, b); } } public void Init() { m_SceneNameT.text = m_SceneData.name; } }