Skip to content

Commit e86e4bc

Browse files
committed
新增:Entity模块。
1 parent 84cac68 commit e86e4bc

24 files changed

+739
-32
lines changed

Editor/Entity.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using UnityEditor;
2+
using UnityEngine;
3+
4+
namespace HT.Framework
5+
{
6+
[CustomEditor(typeof(EntityManager))]
7+
public sealed class EntityManagerInspector : ModuleEditor
8+
{
9+
private EntityManager _target;
10+
11+
protected override void OnEnable()
12+
{
13+
_target = target as EntityManager;
14+
15+
base.OnEnable();
16+
}
17+
18+
protected override void OnPlayingEnable()
19+
{
20+
base.OnPlayingEnable();
21+
}
22+
23+
public override void OnInspectorGUI()
24+
{
25+
GUILayout.BeginHorizontal();
26+
EditorGUILayout.HelpBox("Entity Manager, Control all EntityLogic!", MessageType.Info);
27+
GUILayout.EndHorizontal();
28+
29+
base.OnInspectorGUI();
30+
}
31+
32+
protected override void OnPlayingInspectorGUI()
33+
{
34+
base.OnPlayingInspectorGUI();
35+
36+
GUILayout.BeginVertical("Helpbox");
37+
38+
GUILayout.BeginHorizontal();
39+
GUILayout.Label("Runtime Data", "BoldLabel");
40+
GUILayout.EndHorizontal();
41+
42+
GUILayout.EndVertical();
43+
}
44+
}
45+
}

Editor/Entity/EntityManagerInspector.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/Utility/EditorGlobalTools.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,43 @@ private static void CreateDataSet()
572572
}
573573
}
574574

575+
/// <summary>
576+
/// 新建EntityLogic类
577+
/// </summary>
578+
[@MenuItem("Assets/Create/HTFramework/C# EntityLogic Script", false, 19)]
579+
private static void CreateEntityLogic()
580+
{
581+
string directory = EditorPrefs.GetString(EditorPrefsTable.Script_EntityLogic_Directory, Application.dataPath);
582+
string path = EditorUtility.SaveFilePanel("新建 EntityLogic 类", directory, "NewEntityLogic", "cs");
583+
if (path != "")
584+
{
585+
string className = path.Substring(path.LastIndexOf("/") + 1).Replace(".cs", "");
586+
if (!File.Exists(path))
587+
{
588+
TextAsset asset = AssetDatabase.LoadAssetAtPath("Assets/HTFramework/Editor/Utility/Template/EntityLogicTemplate.txt", typeof(TextAsset)) as TextAsset;
589+
if (asset)
590+
{
591+
string code = asset.text;
592+
code = code.Replace("#SCRIPTNAME#", className);
593+
File.AppendAllText(path, code);
594+
asset = null;
595+
AssetDatabase.Refresh();
596+
597+
string assetPath = path.Substring(path.LastIndexOf("Assets"));
598+
TextAsset cs = AssetDatabase.LoadAssetAtPath(assetPath, typeof(TextAsset)) as TextAsset;
599+
EditorGUIUtility.PingObject(cs);
600+
Selection.activeObject = cs;
601+
AssetDatabase.OpenAsset(cs);
602+
EditorPrefs.SetString(EditorPrefsTable.Script_EntityLogic_Directory, path.Substring(0, path.LastIndexOf("/")));
603+
}
604+
}
605+
else
606+
{
607+
GlobalTools.LogError("新建EntityLogic失败,已存在类型 " + className);
608+
}
609+
}
610+
}
611+
575612
/// <summary>
576613
/// 新建HotfixProcedure类
577614
/// </summary>

Editor/Utility/EditorPrefsTable.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ public static string Script_DataSet_Directory
8989
}
9090
}
9191
/// <summary>
92+
/// 新建EntityLogic脚本的文件夹
93+
/// </summary>
94+
public static string Script_EntityLogic_Directory
95+
{
96+
get
97+
{
98+
return Application.productName + ".HT.Framework.Script.EntityLogic";
99+
}
100+
}
101+
/// <summary>
92102
/// 新建HotfixProcedure脚本的文件夹
93103
/// </summary>
94104
public static string Script_HotfixProcedure_Directory
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
using HT.Framework;
5+
using DG.Tweening;
6+
/// <summary>
7+
/// 新建实体逻辑类
8+
/// </summary>
9+
[EntityResource("AssetBundleName", "AssetPath", "ResourcePath")]
10+
public class #SCRIPTNAME# : EntityLogic
11+
{
12+
/// <summary>
13+
/// 初始化
14+
/// </summary>
15+
public override void OnInit()
16+
{
17+
18+
}
19+
20+
/// <summary>
21+
/// 显示实体
22+
/// </summary>
23+
public override void OnShow()
24+
{
25+
26+
}
27+
28+
/// <summary>
29+
/// 隐藏实体
30+
/// </summary>
31+
public override void OnHide()
32+
{
33+
34+
}
35+
36+
/// <summary>
37+
/// 销毁实体
38+
/// </summary>
39+
public override void OnDestroy()
40+
{
41+
42+
}
43+
44+
/// <summary>
45+
/// 实体逻辑刷新
46+
/// </summary>
47+
public override void OnUpdate()
48+
{
49+
50+
}
51+
52+
/// <summary>
53+
/// 重置实体
54+
/// </summary>
55+
public override void Reset()
56+
{
57+
58+
}
59+
}

Editor/Utility/Template/EntityLogicTemplate.txt.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)