72 lines
2.6 KiB
C#
72 lines
2.6 KiB
C#
using CG.Framework;
|
|
using CG.UTility;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
/*******************************************************************************
|
|
*Create By CG
|
|
*Function
|
|
*******************************************************************************/
|
|
namespace ZXK.GYJQR
|
|
{
|
|
public class HomePanel : UIBase
|
|
{
|
|
private Transform _curSelect = null;
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
InitHomePanel();
|
|
}
|
|
|
|
private void InitHomePanel()
|
|
{
|
|
foreach (EnumCtrl.SystemType item in System.Enum.GetValues(typeof(EnumCtrl.SystemType)))
|
|
{
|
|
if (item != EnumCtrl.SystemType.None)
|
|
{
|
|
if ((int)item > 2) return;
|
|
Transform itemTran = transform.Find("SystemGroup/" + (int)item);
|
|
itemTran.Find("SystemItemPic").GetComponent<Image>().sprite=
|
|
Resources.Load<Sprite>(ConstCtrl.RSC_Folder_SYSTEMLOGOPATH + EnumCtrl.GetEnumDescription(item));
|
|
ButtonExtension itemBtn = null;
|
|
if (!itemTran.TryGetComponent(out itemBtn))
|
|
{
|
|
itemBtn = itemTran.gameObject.AddComponent<ButtonExtension>();
|
|
}
|
|
itemBtn.onCover.AddListener(() =>
|
|
{
|
|
BtnSelectState(itemTran);
|
|
});
|
|
itemBtn.onExit.AddListener(() =>
|
|
{
|
|
BtnResetState(itemTran);
|
|
});
|
|
itemBtn.onClick.AddListener(() =>
|
|
{
|
|
_curSelect = itemTran;
|
|
GameManager.Instance.ChangeType((EnumCtrl.SystemType)int.Parse(itemTran.name));
|
|
GameManager.Instance._StateContext.SetState(
|
|
new ModelSelectState(GameManager.Instance._StateContext));
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
private void BtnSelectState(Transform itemBtn)
|
|
{
|
|
itemBtn.Find("SystemItemBgSelect").gameObject.SetActive(true);
|
|
itemBtn.Find("SystemNameTxt").GetComponent<Text>().color = Color.white;
|
|
}
|
|
private void BtnResetState(Transform itemBtn)
|
|
{
|
|
itemBtn.Find("SystemItemBgSelect").gameObject.SetActive(false);
|
|
itemBtn.Find("SystemNameTxt").GetComponent<Text>().color = Color.black;
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
BtnResetState(_curSelect);
|
|
}
|
|
}
|
|
} |