Kaynağa Gözat

完善了导表工具,在Excel第一行第一列可以指定该配置会被哪些App加载,
比如说,客户端热更层需要加载该配置则指定AppType.ClientH,比如说服务端Gate需要加载则指定AppType.Gate。两者都需要加载则配置 AppType.ClientH | AppType.Gate

tanghai 7 yıl önce
ebeveyn
işleme
b499256903

+ 1 - 0
Config/UnitConfig.txt

@@ -0,0 +1 @@
+{"_id":1001,"Name":"米克尔","Desc":"带有强力攻击技能","Position":1,"Height":178,"Weight":68}

BIN
Excel/UnitConfig.xlsx


+ 17 - 0
Server/Model/Entity/Config/UnitConfig.cs

@@ -0,0 +1,17 @@
+namespace ETModel
+{
+	[Config(AppType.ClientH |  AppType.ClientM | AppType.Gate | AppType.Map)]
+	public partial class UnitConfigCategory : ACategory<UnitConfig>
+	{
+	}
+
+	public class UnitConfig: IConfig
+	{
+		public long Id { get; set; }
+		public string Name;
+		public string Desc;
+		public int Position;
+		public int Height;
+		public int Weight;
+	}
+}

+ 18 - 25
Unity/Assets/Editor/ExcelExporterEditor/ExcelExporterEditor.cs

@@ -41,7 +41,8 @@ public class ExcelExporterEditor : EditorWindow
 		GetWindow(typeof(ExcelExporterEditor));
 	}
 
-	private const string ExcelPath = @"..\Excel";
+	private const string ExcelPath = "../Excel";
+	private const string ServerConfigPath = "../Config/";
 
 	private bool isClient;
 
@@ -52,38 +53,30 @@ public class ExcelExporterEditor : EditorWindow
 	{
 		try
 		{
-			const string clientPath = @".\Assets\Res\Config";
-
-			string serverPath = EditorPrefs.GetString("serverPath");
-			serverPath = EditorGUILayout.TextField("服务端配置路径:", serverPath);
-			EditorPrefs.SetString("serverPath", serverPath);
+			const string clientPath = "./Assets/Res/Config";
 
 			if (GUILayout.Button("导出客户端配置"))
 			{
 				this.isClient = true;
+				
 				ExportAll(clientPath);
+				
+				ExportAllClass(@"./Assets/Model/Entity/Config", "namespace ETModel\n{\n");
+				ExportAllClass(@"./Assets/Hotfix/Entity/Config", "using ETModel;\n\nnamespace ETHotfix\n{\n");
+				
+				Log.Info($"导出客户端配置完成!");
 			}
 
 			if (GUILayout.Button("导出服务端配置"))
 			{
 				this.isClient = false;
-				if (serverPath == "")
-				{
-					Log.Error("请输入服务端配置路径!");
-					return;
-				}
-				ExportAll(serverPath);
-			}
-
-			if (GUILayout.Button("生成Model配置类"))
-			{
-				ExportAllClass(@".\Assets\Model\Entity\Config", "namespace ETModel\n{\n");
+				
+				ExportAll(ServerConfigPath);
+				
+				ExportAllClass(@"../Server/Model/Entity/Config", "namespace ETModel\n{\n");
+				
+				Log.Info($"导出服务端配置完成!");
 			}
-
-            if (GUILayout.Button("生成Hofix配置类"))
-            {
-                ExportAllClass(@".\Assets\Hotfix\Entity\Config", "using ETModel;\n\nnamespace ETHotfix\n{\n");
-            }
         }
 		catch (Exception e)
 		{
@@ -105,8 +98,8 @@ public class ExcelExporterEditor : EditorWindow
 			}
 
 			ExportClass(filePath, exportDir, csHead);
+			Log.Info($"生成{Path.GetFileName(filePath)}类");
 		}
-		Log.Debug("生成类完成!");
 		AssetDatabase.Refresh();
 	}
 
@@ -119,7 +112,7 @@ public class ExcelExporterEditor : EditorWindow
 		}
 
 		string protoName = Path.GetFileNameWithoutExtension(fileName);
-		Log.Info($"{protoName}生成class开始");
+		
 		string exportPath = Path.Combine(exportDir, $"{protoName}.cs");
 		using (FileStream txt = new FileStream(exportPath, FileMode.Create))
 		using (StreamWriter sw = new StreamWriter(txt))
@@ -128,7 +121,7 @@ public class ExcelExporterEditor : EditorWindow
 			ISheet sheet = xssfWorkbook.GetSheetAt(0);
 			sb.Append(csHead);
 
-			sb.Append("\t[Config(AppType.Client)]\n");
+			sb.Append($"\t[Config({GetCellString(sheet, 0, 0)})]\n");
 			sb.Append($"\tpublic partial class {protoName}Category : ACategory<{protoName}>\n");
 			sb.Append("\t{\n");
 			sb.Append("\t}\n\n");

+ 0 - 48
Unity/Assets/Editor/ExportNavmesh.cs

@@ -1,48 +0,0 @@
-/************************************************ 
- * 文件名:ExportNavMesh.cs 
- * 描述:导出NavMesh数据给服务器使用 
- * 创建人:陈鹏 
- * 创建日期:20160926 
- * http://blog.csdn.net/huutu/article/details/52672505 
- * ************************************************/
-
-using UnityEngine;
-using UnityEditor;
-using System.IO;
-using UnityEngine.AI;
-using UnityEngine.SceneManagement;
-
-public class ExportNavMesh
-{
-	[MenuItem("NavMesh/Export")]
-	static void Export()
-	{
-		Debug.Log("ExportNavMesh");
-
-		NavMeshTriangulation tmpNavMeshTriangulation = NavMesh.CalculateTriangulation();
-
-		//新建文件  
-		string tmpPath = Application.dataPath + "/" + SceneManager.GetActiveScene().name + ".obj";
-		StreamWriter tmpStreamWriter = new StreamWriter(tmpPath);
-
-		//顶点  
-		for (int i = 0; i < tmpNavMeshTriangulation.vertices.Length; i++)
-		{
-			tmpStreamWriter.WriteLine("v  " + tmpNavMeshTriangulation.vertices[i].x + " " + tmpNavMeshTriangulation.vertices[i].y + " " + tmpNavMeshTriangulation.vertices[i].z);
-		}
-
-		tmpStreamWriter.WriteLine("g pPlane1");
-
-		//索引  
-		for (int i = 0; i < tmpNavMeshTriangulation.indices.Length;)
-		{
-			tmpStreamWriter.WriteLine("f " + (tmpNavMeshTriangulation.indices[i] + 1) + " " + (tmpNavMeshTriangulation.indices[i + 1] + 1) + " " + (tmpNavMeshTriangulation.indices[i + 2] + 1));
-			i = i + 3;
-		}
-
-		tmpStreamWriter.Flush();
-		tmpStreamWriter.Close();
-
-		Debug.Log("ExportNavMesh Success");
-	}
-}

+ 0 - 12
Unity/Assets/Editor/ExportNavmesh.cs.meta

@@ -1,12 +0,0 @@
-fileFormatVersion: 2
-guid: d2594920a38028d408bde3caef3194c3
-timeCreated: 1497608266
-licenseType: Free
-MonoImporter:
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 2 - 2
Unity/Assets/Editor/LogRedirection.cs

@@ -23,7 +23,7 @@ internal static class LogRedirection
             return false;
         }
 
-        if (!selectedStackTrace.Contains("Model.Log"))
+        if (!selectedStackTrace.Contains("ETModel.Log"))
         {
             return false;
         }
@@ -40,7 +40,7 @@ internal static class LogRedirection
         {
             return false;
         }
-        if (!selectedStackTrace.Contains("Hotfix.Log"))
+        if (!selectedStackTrace.Contains("ETHotfix.Log"))
         {
             InternalEditorUtility.OpenFileAtLineExternal(Application.dataPath.Replace("Assets", "") + match.Groups[1].Value, int.Parse(match.Groups[2].Value));
 

+ 2 - 2
Unity/Assets/Hotfix/Entity/Config/UnitConfig.cs

@@ -2,12 +2,12 @@ using ETModel;
 
 namespace ETHotfix
 {
-	[Config(AppType.Client)]
+	[Config(AppType.ClientH |  AppType.ClientM | AppType.Gate | AppType.Map)]
 	public partial class UnitConfigCategory : ACategory<UnitConfig>
 	{
 	}
 
-	public class UnitConfig : IConfig
+	public class UnitConfig: IConfig
 	{
 		public long Id { get; set; }
 		public string Name;

+ 8 - 0
Unity/Assets/Hotfix/Module/Config/ConfigComponent.cs

@@ -46,6 +46,14 @@ namespace ETHotfix
 				{
 					continue;
 				}
+				
+				ConfigAttribute configAttribute = attrs[0] as ConfigAttribute;
+				// 只加载指定的配置
+				if (!configAttribute.Type.Is(AppType.ClientH))
+				{
+					continue;
+				}
+				
 				object obj = Activator.CreateInstance(type);
 
 				ACategory iCategory = obj as ACategory;

+ 1 - 1
Unity/Assets/Model/Entity/Config/UnitConfig.cs

@@ -1,6 +1,6 @@
 namespace ETModel
 {
-	[Config(AppType.Client)]
+	[Config(AppType.ClientH |  AppType.ClientM | AppType.Gate | AppType.Map)]
 	public partial class UnitConfigCategory : ACategory<UnitConfig>
 	{
 	}

+ 7 - 0
Unity/Assets/Model/Module/Config/ConfigComponent.cs

@@ -46,6 +46,13 @@ namespace ETModel
 					continue;
 				}
 				
+				ConfigAttribute configAttribute = attrs[0] as ConfigAttribute;
+				// 只加载指定的配置
+				if (!configAttribute.Type.Is(AppType.ClientM))
+				{
+					continue;
+				}
+				
 				object obj = Activator.CreateInstance(type);
 
 				ACategory iCategory = obj as ACategory;

+ 8 - 5
Unity/Assets/Model/Other/AppType.cs

@@ -15,11 +15,14 @@ namespace ETModel
 		Location = 1 << 5,
 		Map = 1 << 6,
 
-		BenchmarkWebsocketServer = 1 << 27,
-		BenchmarkWebsocketClient = 1 << 28,
-		Robot = 1 << 29,
-		Benchmark = 1 << 30,
-		Client = 1 << 31,
+		BenchmarkWebsocketServer = 1 << 26,
+		BenchmarkWebsocketClient = 1 << 27,
+		Robot = 1 << 28,
+		Benchmark = 1 << 29,
+		// 客户端Hotfix层
+		ClientH = 1 << 30,
+		// 客户端Model层
+		ClientM = 1 << 31,
 
 		// 7
 		AllServer = Manager | Realm | Gate | Http | DB | Location | Map | BenchmarkWebsocketServer

+ 6 - 6
Unity/Unity.sln

@@ -5,10 +5,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Model", "Unity.Model.
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.ThirdParty", "Unity.ThirdParty.csproj", "{CFBC0A95-3456-3439-6B2E-60FDE0FE5EE1}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Editor", "Unity.Editor.csproj", "{C17F48D3-964E-E97C-3D2E-966F7A6C6D93}"
-EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Hotfix", "Unity.Hotfix.csproj", "{350246F3-F094-675F-855B-FB9B18C2B23E}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Editor", "Unity.Editor.csproj", "{C17F48D3-964E-E97C-3D2E-966F7A6C6D93}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -23,14 +23,14 @@ Global
 		{CFBC0A95-3456-3439-6B2E-60FDE0FE5EE1}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{CFBC0A95-3456-3439-6B2E-60FDE0FE5EE1}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{CFBC0A95-3456-3439-6B2E-60FDE0FE5EE1}.Release|Any CPU.Build.0 = Release|Any CPU
-		{C17F48D3-964E-E97C-3D2E-966F7A6C6D93}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{C17F48D3-964E-E97C-3D2E-966F7A6C6D93}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{C17F48D3-964E-E97C-3D2E-966F7A6C6D93}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{C17F48D3-964E-E97C-3D2E-966F7A6C6D93}.Release|Any CPU.Build.0 = Release|Any CPU
 		{350246F3-F094-675F-855B-FB9B18C2B23E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{350246F3-F094-675F-855B-FB9B18C2B23E}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{350246F3-F094-675F-855B-FB9B18C2B23E}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{350246F3-F094-675F-855B-FB9B18C2B23E}.Release|Any CPU.Build.0 = Release|Any CPU
+		{C17F48D3-964E-E97C-3D2E-966F7A6C6D93}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{C17F48D3-964E-E97C-3D2E-966F7A6C6D93}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{C17F48D3-964E-E97C-3D2E-966F7A6C6D93}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{C17F48D3-964E-E97C-3D2E-966F7A6C6D93}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE