组件导出代码
This commit is contained in:
@@ -113,7 +113,7 @@ public class UIComponentExportEditor : Editor
|
|||||||
sb.AppendLine("{");
|
sb.AppendLine("{");
|
||||||
sb.AppendLine($" public partial class {className} : UIComponentBase");
|
sb.AppendLine($" public partial class {className} : UIComponentBase");
|
||||||
sb.AppendLine(" {");
|
sb.AppendLine(" {");
|
||||||
sb.AppendLine($" public override string PrefabPath => \"Prefabs/UI/{target.GameObject().name}\";");
|
// sb.AppendLine($" public override string PrefabPath => \"Prefabs/UI/{target.GameObject().name}\";");
|
||||||
|
|
||||||
// 字段定义
|
// 字段定义
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,40 @@ namespace CreatGame.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class UIComponentBase : MonoBehaviour
|
public class UIComponentBase : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 窗口预制件
|
||||||
|
/// </summary>
|
||||||
|
protected GameObject m_ComponentObject;
|
||||||
|
/// <summary>
|
||||||
|
/// 导出脚本
|
||||||
|
/// </summary>
|
||||||
|
protected UIViewExport m_ViewExport;
|
||||||
|
/// <summary>
|
||||||
|
/// 是否加载完成
|
||||||
|
/// </summary>
|
||||||
|
public bool IsPreLoad = false;
|
||||||
|
public virtual void PreLoad(GameObject obj)
|
||||||
|
{
|
||||||
|
m_ComponentObject = obj;
|
||||||
|
m_ViewExport = obj.GetComponent<UIViewExport>();
|
||||||
|
IsPreLoad = true;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
protected GameObject GetGameObject(string name)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < m_ViewExport.entries.Count; i++)
|
||||||
|
{
|
||||||
|
if (m_ViewExport.entries[i].key == name)
|
||||||
|
{
|
||||||
|
return m_ViewExport.entries[i].prefab;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user