12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class SChooseItem : MonoBehaviour
- {
- /// <summary>
- /// 当选择场景时触发事件
- /// </summary>
- public event Action<SceneValue, bool> 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<Toggle>();
- m_SceneImage = transform.Find("Scene").GetComponent<Image>();
- m_SceneNameT = m_Toggle.transform.Find("Label").GetComponent<Text>();
- 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;
- }
- }
|