From 77d07e175a3a76b93c9562ab637040ba08140f1b Mon Sep 17 00:00:00 2001
From: Alex-Rachel <574809918@qq.com>
Date: Wed, 12 Mar 2025 11:40:05 +0800
Subject: [PATCH] =?UTF-8?q?LubanTools=E6=94=AF=E6=8C=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../GameConfig/CustomTemplate/ConfigSystem.cs | 16 +++++++++++----
.../Assets/TEngine/Editor/LubanTools.meta | 3 +++
.../TEngine/Editor/LubanTools/LubanTools.cs | 20 +++++++++++++++++++
.../Editor/LubanTools/LubanTools.cs.meta | 3 +++
.../TEngine/Editor/Utility/ShellHelper.cs | 8 ++++++++
5 files changed, 46 insertions(+), 4 deletions(-)
create mode 100644 UnityProject/Assets/TEngine/Editor/LubanTools.meta
create mode 100644 UnityProject/Assets/TEngine/Editor/LubanTools/LubanTools.cs
create mode 100644 UnityProject/Assets/TEngine/Editor/LubanTools/LubanTools.cs.meta
diff --git a/Configs/GameConfig/CustomTemplate/ConfigSystem.cs b/Configs/GameConfig/CustomTemplate/ConfigSystem.cs
index 4098e05c..f12c5e59 100644
--- a/Configs/GameConfig/CustomTemplate/ConfigSystem.cs
+++ b/Configs/GameConfig/CustomTemplate/ConfigSystem.cs
@@ -1,5 +1,4 @@
using Luban;
-using GameBase;
using GameConfig;
using TEngine;
using UnityEngine;
@@ -7,8 +6,12 @@ using UnityEngine;
///
/// 配置加载器。
///
-public class ConfigSystem : Singleton
+public class ConfigSystem
{
+ private static ConfigSystem _instance;
+
+ public static ConfigSystem Instance => _instance ??= new ConfigSystem();
+
private bool _init = false;
private Tables _tables;
@@ -25,6 +28,8 @@ public class ConfigSystem : Singleton
return _tables;
}
}
+
+ private IResourceModule _resourceModule;
///
/// 加载配置。
@@ -42,9 +47,12 @@ public class ConfigSystem : Singleton
/// ByteBuf
private ByteBuf LoadByteBuf(string file)
{
- TextAsset textAsset = GameModule.Resource.LoadAsset(file);
+ if (_resourceModule == null)
+ {
+ _resourceModule = ModuleSystem.GetModule();
+ }
+ TextAsset textAsset = _resourceModule.LoadAsset(file);
byte[] bytes = textAsset.bytes;
- GameModule.Resource.UnloadAsset(textAsset);
return new ByteBuf(bytes);
}
}
\ No newline at end of file
diff --git a/UnityProject/Assets/TEngine/Editor/LubanTools.meta b/UnityProject/Assets/TEngine/Editor/LubanTools.meta
new file mode 100644
index 00000000..29bf3068
--- /dev/null
+++ b/UnityProject/Assets/TEngine/Editor/LubanTools.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: caeffc4d6ca44936a5c2e191a6ef906e
+timeCreated: 1741750069
\ No newline at end of file
diff --git a/UnityProject/Assets/TEngine/Editor/LubanTools/LubanTools.cs b/UnityProject/Assets/TEngine/Editor/LubanTools/LubanTools.cs
new file mode 100644
index 00000000..0d495efa
--- /dev/null
+++ b/UnityProject/Assets/TEngine/Editor/LubanTools/LubanTools.cs
@@ -0,0 +1,20 @@
+using UnityEditor;
+using UnityEngine;
+
+namespace TEngine.Editor
+{
+ public static class LubanTools
+ {
+ [MenuItem("TEngine/Luban/转表 &X", priority = -100)]
+ private static void ZhuanXiaoYi()
+ {
+#if UNITY_EDITOR_OSX || UNITY_EDITOR_LINUX
+ string path = Application.dataPath + "/../../Configs/GameConfig/gen_code_bin_to_project_lazyload.sh";
+#elif UNITY_EDITOR_WIN
+ string path = Application.dataPath + "/../../Configs/GameConfig/gen_code_bin_to_project_lazyload.bat";
+#endif
+ Debug.Log($"执行转表:{path}");
+ ShellHelper.RunByPath(path);
+ }
+ }
+}
\ No newline at end of file
diff --git a/UnityProject/Assets/TEngine/Editor/LubanTools/LubanTools.cs.meta b/UnityProject/Assets/TEngine/Editor/LubanTools/LubanTools.cs.meta
new file mode 100644
index 00000000..d639ec4e
--- /dev/null
+++ b/UnityProject/Assets/TEngine/Editor/LubanTools/LubanTools.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 16ad4ede8ed745f3b6f90b58b7427f5e
+timeCreated: 1741750081
\ No newline at end of file
diff --git a/UnityProject/Assets/TEngine/Editor/Utility/ShellHelper.cs b/UnityProject/Assets/TEngine/Editor/Utility/ShellHelper.cs
index bcd8b5ae..74d3cfd6 100644
--- a/UnityProject/Assets/TEngine/Editor/Utility/ShellHelper.cs
+++ b/UnityProject/Assets/TEngine/Editor/Utility/ShellHelper.cs
@@ -102,5 +102,13 @@ namespace TEngine.Editor
process.Close();
}
}
+
+ public static void RunByPath(string path)
+ {
+ if (!string.IsNullOrEmpty(path))
+ {
+ Process.Start(path);
+ }
+ }
}
}
\ No newline at end of file