代码导出工具
This commit is contained in:
27
UnityGame/Assets/Scripts/GameLogic/Export/UGUI/UIMainView.cs
Normal file
27
UnityGame/Assets/Scripts/GameLogic/Export/UGUI/UIMainView.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using CreatGame.UI;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace CreatGame.UI
|
||||
{
|
||||
public class UIMainView : UIViewBase
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public Button StarBtn;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public Text StarBtnText;
|
||||
public override void PreLoad(GameObject view)
|
||||
{
|
||||
base.PreLoad(view);
|
||||
|
||||
StarBtn = GetGameObject(nameof(StarBtn)).GetComponent<Button>();
|
||||
StarBtnText = GetGameObject(nameof(StarBtnText)).GetComponent<Text>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8c5ae2248a663cd4f9fc66ca55751f19
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -26,7 +26,6 @@ namespace CreatGame.UI
|
||||
{
|
||||
var view = new T();
|
||||
|
||||
view.PreLoad();
|
||||
view.InitView();
|
||||
return view;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace CreatGame.UI
|
||||
using UnityEngine;
|
||||
|
||||
namespace CreatGame.UI
|
||||
{
|
||||
public class UIViewBase
|
||||
{
|
||||
@@ -7,10 +9,21 @@
|
||||
/// </summary>
|
||||
public virtual string PrefabPath { get; set; }
|
||||
/// <summary>
|
||||
/// 窗口预制件
|
||||
/// </summary>
|
||||
protected GameObject m_ViewObject;
|
||||
/// <summary>
|
||||
/// 导出脚本
|
||||
/// </summary>
|
||||
protected UIExportTool m_ExportTool;
|
||||
/// <summary>
|
||||
/// 加载窗口的时候需要预先加载的东西
|
||||
/// </summary>
|
||||
public virtual void PreLoad()
|
||||
public virtual void PreLoad(GameObject viewObject)
|
||||
{
|
||||
m_ViewObject = viewObject;
|
||||
|
||||
m_ExportTool = viewObject.GetComponent<UIExportTool>();
|
||||
}
|
||||
/// <summary>
|
||||
/// 初始化界面
|
||||
@@ -26,5 +39,18 @@
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected GameObject GetGameObject(string name)
|
||||
{
|
||||
for (int i = 0; i < m_ExportTool.entries.Count; i++)
|
||||
{
|
||||
if (m_ExportTool.entries[i].key == name)
|
||||
{
|
||||
return m_ExportTool.entries[i].prefab;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user