add :添加一部分UI预制体的代码内容

pull/1/head
zxl 2024-11-01 15:06:32 +08:00
parent 73a0b04dee
commit 49071b8ac6
7 changed files with 134 additions and 0 deletions

View File

@ -0,0 +1,43 @@
using System;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
namespace ZC
{
[UIType(UIType.AnalysisReportUI)]
public class AnalysisReportUI : UIBase
{
private TMP_Text txt_Title;
private TMP_Text txt_Content;
private Image img_Pic;
private Button btn_Close;
private Action closeAction;
public override void Init()
{
base.Init();
this.txt_Title = self.transform.FindChildDeep<TMP_Text>("txt_Title");
this.txt_Content = self.transform.FindChildDeep<TMP_Text>("txt_Content");
this.img_Pic = self.transform.FindChildDeep<Image>("img_Pic");
this.btn_Close = self.transform.FindChildDeep<Button>("btn_Close");
btn_Close.onClick.AddListener(ClickClose);
}
private void ClickClose()
{
ZCGame.UIManager.HideUI(UIType.AnalysisReportUI);
closeAction?.Invoke();
closeAction = null;
}
public void SetData(string title, Sprite sprite, string content, Action callback = null)
{
txt_Title.text = title;
img_Pic.sprite = sprite;
txt_Content.text = content;
closeAction = callback;
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: bbbe8e7dd2a14e8e883c315c6548fadc
timeCreated: 1730441581

View File

@ -0,0 +1,40 @@
using System;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
namespace ZC
{
[UIType(UIType.IntroduceUI)]
public class IntroduceUI : UIBase
{
private TMP_Text txt_Title;
private TMP_Text txt_Content;
private Button btn_Close;
private Action closeAction;
public override void Init()
{
base.Init();
this.txt_Title = self.transform.FindChildDeep<TMP_Text>("txt_Title");
this.txt_Content = self.transform.FindChildDeep<TMP_Text>("txt_Content");
this.btn_Close = self.transform.FindChildDeep<Button>("btn_Close");
btn_Close.onClick.AddListener(ClickClose);
}
private void ClickClose()
{
ZCGame.UIManager.HideUI(UIType.IntroduceUI);
closeAction?.Invoke();
closeAction = null;
}
public void SetData(string title, string content, Action callback = null)
{
txt_Title.text = title;
txt_Content.text = content;
closeAction = callback;
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: feafec9a827447d589afa0c665de32a0
timeCreated: 1730442480

View File

@ -0,0 +1,39 @@
using System;
using TMPro;
using UnityEngine.UI;
namespace ZC
{
[UIType(UIType.MinTipsUI)]
public class MinTipsUI : UIBase
{
private TMP_Text txt_Title;
private TMP_Text txt_Content;
private Button btn_Close;
private Action closeAction;
public override void Init()
{
base.Init();
this.txt_Title = self.transform.FindChildDeep<TMP_Text>("txt_Title");
this.txt_Content = self.transform.FindChildDeep<TMP_Text>("txt_Content");
this.btn_Close = self.transform.FindChildDeep<Button>("btn_Close");
btn_Close.onClick.AddListener(ClickClose);
}
private void ClickClose()
{
ZCGame.UIManager.HideUI(UIType.IntroduceUI);
closeAction?.Invoke();
closeAction = null;
}
public void SetData(string title, string content, Action callback = null)
{
txt_Title.text = title;
txt_Content.text = content;
closeAction = callback;
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f3a6ff210a2c4f5098ef1a728f5021dd
timeCreated: 1730442815

View File

@ -5,6 +5,9 @@
LoadingUI, LoadingUI,
GameUI, GameUI,
AnswerUI, AnswerUI,
AnalysisReportUI,
IntroduceUI,
MinTipsUI
} }
public enum UILayer public enum UILayer