127 lines
3.6 KiB
C#
127 lines
3.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine.UI;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
namespace ZC
|
|
{
|
|
[UIType(UIType.ModelDisplayUI)]
|
|
public class ModelDisplayUI : UIBase
|
|
{
|
|
#region AutoGen_InitIon
|
|
|
|
public Button btn_Left;
|
|
public Button btn_Right;
|
|
public TMP_Text txt_Name;
|
|
public Button btn_Close;
|
|
public Button btn_EquipItem;
|
|
public TMP_Text txt_EquipItemName;
|
|
public TMP_Text txt_Title;
|
|
|
|
#endregion
|
|
|
|
List<Transform> _listObj = new List<Transform>();
|
|
private Transform currentObj;
|
|
Action callBack;
|
|
|
|
public override void Init()
|
|
{
|
|
base.Init();
|
|
|
|
#region AutoGen_Init
|
|
|
|
btn_Left = GetValue<Button>("btn_Left");
|
|
btn_Right = GetValue<Button>("btn_Right");
|
|
txt_Name = GetValue<TMP_Text>("txt_Name");
|
|
btn_Close = GetValue<Button>("btn_Close");
|
|
btn_EquipItem = GetValue<Button>("btn_EquipItem");
|
|
txt_EquipItemName = GetValue<TMP_Text>("txt_EquipItemName");
|
|
txt_Title = GetValue<TMP_Text>("txt_Title");
|
|
|
|
btn_Left.onClick.AddListener(OnClickbtn_Left);
|
|
btn_Right.onClick.AddListener(OnClickbtn_Right);
|
|
btn_Close.onClick.AddListener(OnClickbtn_Close);
|
|
btn_EquipItem.onClick.AddListener(OnClickbtn_EquipItem);
|
|
|
|
#endregion
|
|
|
|
var camera = self.transform.FindChildDeep<Camera>("Camera");
|
|
foreach (Transform tran in camera.transform.GetChild(0))
|
|
{
|
|
var itemGo = GameObject.Instantiate(btn_EquipItem.gameObject, btn_EquipItem.transform.parent);
|
|
var binding = itemGo.GetComponent<GameObjectBinding>();
|
|
binding.GetValue<Button>("btn_EquipItem").onClick.AddListener(() =>
|
|
{
|
|
foreach (var transform1 in _listObj)
|
|
{
|
|
transform1.gameObject.SetActive(false);
|
|
}
|
|
|
|
txt_Name.text = tran.name;
|
|
tran.gameObject.SetActive(true);
|
|
});
|
|
binding.GetValue<TMP_Text>("txt_EquipItemName").text = tran.name;
|
|
_listObj.Add(tran);
|
|
}
|
|
|
|
{
|
|
foreach (var transform1 in _listObj)
|
|
{
|
|
transform1.gameObject.SetActive(false);
|
|
}
|
|
|
|
txt_Name.text = _listObj[0].name;
|
|
_listObj[0].gameObject.SetActive(true);
|
|
}
|
|
}
|
|
|
|
public void SetData(Action callback)
|
|
{
|
|
this.callBack = callback;
|
|
}
|
|
|
|
#region AutoGen_Method
|
|
|
|
private void OnClickbtn_Left()
|
|
{
|
|
}
|
|
|
|
private void OnClickbtn_Right()
|
|
{
|
|
}
|
|
|
|
private void OnClickbtn_Close()
|
|
{
|
|
callBack?.Invoke();
|
|
}
|
|
|
|
private void OnClickbtn_EquipItem()
|
|
{
|
|
}
|
|
|
|
#endregion
|
|
|
|
public override void Dispose()
|
|
{
|
|
base.Dispose();
|
|
|
|
#region AutoGen_Dispose
|
|
|
|
btn_Left.onClick.RemoveListener(OnClickbtn_Left);
|
|
btn_Right.onClick.RemoveListener(OnClickbtn_Right);
|
|
btn_Close.onClick.RemoveListener(OnClickbtn_Close);
|
|
btn_EquipItem.onClick.RemoveListener(OnClickbtn_EquipItem);
|
|
|
|
btn_Left = null;
|
|
btn_Right = null;
|
|
txt_Name = null;
|
|
btn_Close = null;
|
|
btn_EquipItem = null;
|
|
txt_EquipItemName = null;
|
|
txt_Title = null;
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
} |