2025-07-16 18:10:09 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace CreatGame.UI
|
2025-07-15 15:33:35 +08:00
|
|
|
|
{
|
|
|
|
|
|
public class UIViewBase
|
|
|
|
|
|
{
|
2025-07-16 13:36:21 +08:00
|
|
|
|
/// <summary>
|
2025-07-16 19:16:46 +08:00
|
|
|
|
/// 预制件的Addressables地址
|
|
|
|
|
|
/// 由导出代码自己添加
|
2025-07-16 13:36:21 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public virtual string PrefabPath { get; set; }
|
|
|
|
|
|
/// <summary>
|
2025-07-16 18:10:09 +08:00
|
|
|
|
/// 窗口预制件
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
protected GameObject m_ViewObject;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 导出脚本
|
|
|
|
|
|
/// </summary>
|
2025-07-20 01:24:55 +08:00
|
|
|
|
protected UIViewExport MViewExport;
|
2025-07-16 18:10:09 +08:00
|
|
|
|
/// <summary>
|
2025-07-16 19:16:46 +08:00
|
|
|
|
/// 是否加载完成
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool IsPreLoad = false;
|
|
|
|
|
|
/// <summary>
|
2025-07-16 13:36:21 +08:00
|
|
|
|
/// 加载窗口的时候需要预先加载的东西
|
|
|
|
|
|
/// </summary>
|
2025-07-16 18:10:09 +08:00
|
|
|
|
public virtual void PreLoad(GameObject viewObject)
|
2025-07-16 13:36:21 +08:00
|
|
|
|
{
|
2025-07-16 18:10:09 +08:00
|
|
|
|
m_ViewObject = viewObject;
|
2025-07-20 01:24:55 +08:00
|
|
|
|
MViewExport = viewObject.GetComponent<UIViewExport>();
|
2025-07-16 19:16:46 +08:00
|
|
|
|
IsPreLoad = true;
|
2025-07-16 13:36:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 初始化界面
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public virtual void InitView()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 关闭窗口的时候的调用
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public virtual void CloseView()
|
|
|
|
|
|
{
|
2025-07-17 09:52:33 +08:00
|
|
|
|
GameObject.Destroy(m_ViewObject);
|
2025-07-16 13:36:21 +08:00
|
|
|
|
}
|
2025-07-16 18:10:09 +08:00
|
|
|
|
|
|
|
|
|
|
protected GameObject GetGameObject(string name)
|
|
|
|
|
|
{
|
2025-07-20 01:24:55 +08:00
|
|
|
|
for (int i = 0; i < MViewExport.entries.Count; i++)
|
2025-07-16 18:10:09 +08:00
|
|
|
|
{
|
2025-07-20 01:24:55 +08:00
|
|
|
|
if (MViewExport.entries[i].key == name)
|
2025-07-16 18:10:09 +08:00
|
|
|
|
{
|
2025-07-20 01:24:55 +08:00
|
|
|
|
return MViewExport.entries[i].prefab;
|
2025-07-16 18:10:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
2025-07-15 15:33:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|