Kaynağa Gözat

关卡编辑器连接出怪表的sheet

wgl 6 ay önce
ebeveyn
işleme
f31a121635

+ 21 - 8
ActionTowerDefense/Assets/GameLevelEditor/GameMap/CoreScripts/Editor/GameMapEditor.cs

@@ -5,6 +5,7 @@ using UnityEngine;
 using UnityEditor;
 using System.Linq;
 
+
 public class GameMapEditor : EditorWindow
 {
 	// ----------------------------------------------------------------------------------------------------------------
@@ -111,6 +112,7 @@ public class GameMapEditor : EditorWindow
 	private StyleDefs _styles = null;
 	private StyleDefs Styles { get { return _styles ?? (_styles = new StyleDefs()); } }
 
+	private static readonly GUIContent GC_ExcelReload = new GUIContent("-reload-");
 	private static readonly GUIContent GC_MapSelect = new GUIContent("-select-");
 	private static readonly GUIContent GC_EditorHead = new GUIContent("Editor");
 	private static readonly GUIContent GC_AssetHead = new GUIContent("Asset");
@@ -517,13 +519,13 @@ public class GameMapEditor : EditorWindow
 			gridColor = EditorGUILayout.ColorField(GC_GridCol, gridColor);
 			if (EditorGUI.EndChangeCheck()) EditorPrefs_SetColor("plyGameMapEd.gridColor", gridColor);
 
-			EditorGUI.BeginChangeCheck();
-			outsideMapIsSolid = EditorGUILayout.Toggle(GC_Solid, outsideMapIsSolid);
-			if (EditorGUI.EndChangeCheck()) EditorPrefs.SetBool("plyGameMapEd.outsideMapIsSolid", outsideMapIsSolid);
+			//EditorGUI.BeginChangeCheck();
+			//outsideMapIsSolid = EditorGUILayout.Toggle(GC_Solid, outsideMapIsSolid);
+			//if (EditorGUI.EndChangeCheck()) EditorPrefs.SetBool("plyGameMapEd.outsideMapIsSolid", outsideMapIsSolid);
 
-			EditorGUI.BeginChangeCheck();
-			refTileSz = EditorGUILayout.FloatField(GC_AutoSz, refTileSz);
-			if (EditorGUI.EndChangeCheck()) EditorPrefs.SetFloat("plyGameMapEd.refTileSz", refTileSz);
+			//EditorGUI.BeginChangeCheck();
+			//refTileSz = EditorGUILayout.FloatField(GC_AutoSz, refTileSz);
+			//if (EditorGUI.EndChangeCheck()) EditorPrefs.SetFloat("plyGameMapEd.refTileSz", refTileSz);
 
 			EditorGUILayout.Space();
 		}
@@ -615,9 +617,18 @@ public class GameMapEditor : EditorWindow
 		{
 			// map selection button
 			r.height = EditorGUIUtility.singleLineHeight;
-			r.x = r.xMax - 103f; r.width = 100f; r.height = 15f;
+			r.x = r.xMax - 200f; r.width = 100f; r.height = 15f;
+            if (GUI.Button(r, GC_ExcelReload))
+            {
+				List<string> excelWorksheets = ExcelEditor.ReadExcelSheetsInfo("Luban/Config/Datas/出怪表.xlsx");
+				for (int i = 0; i < excelWorksheets.Count; i++)
+				{
+					asset.maps[i].ident = excelWorksheets[i];
+				}
+			}
+			r.x = r.xMax; r.width = 100f; r.height = 15f;
 			if (GUI.Button(r, GC_MapSelect))
-			{
+            {
 				mapsPopup.Asset = asset;
 				mapsPopup.OnMapSelected = OnMapSelected;
 				PopupWindow.Show(r, mapsPopup);
@@ -684,6 +695,8 @@ public class GameMapEditor : EditorWindow
 		EditorGUILayout.EndVertical();
 	}
 
+
+
 	private void OnMapSelected(int idx)
 	{
 		if (mapIdx == idx) return;

+ 14 - 3
ActionTowerDefense/Assets/GameLevelEditor/GameMap/CoreScripts/Editor/GameMapTextEd.cs

@@ -1,9 +1,11 @@
 using UnityEngine;
 using UnityEditor;
-
+using OfficeOpenXml;
+using System.IO;
 
 public class GameMapTextEd : EditorWindow
 {
+	public string oldText;
 	public string text { get; private set; }
 
 	private string label;
@@ -41,12 +43,21 @@ public class GameMapTextEd : EditorWindow
 
 		EditorGUILayout.Space();
 		GUILayout.Label(label);
-		text = EditorGUILayout.TextField(text);
+		string newText = EditorGUILayout.TextField(text);
+		if(newText != text)
+        {
+			oldText = text;
+			text = newText;
+        }
 		GUILayout.FlexibleSpace();
 		EditorGUILayout.BeginHorizontal(BottomBarStyle);
 		{
 			GUILayout.FlexibleSpace();
-			if (GUILayout.Button("Accept", GUILayout.Width(80))) accepted = true;
+			if (GUILayout.Button("Accept", GUILayout.Width(80)))
+			{
+				accepted = true;
+				ExcelEditor.RenameSheet("Luban/Config/Datas/出怪表.xlsx", oldText, text);
+			}
 			GUILayout.Space(5);
 			if (GUILayout.Button("Cancel", GUILayout.Width(80))) Close();
 			GUILayout.FlexibleSpace();

+ 8 - 0
ActionTowerDefense/Assets/NuGet.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: dbf134857daf7df428aa31cdd055514f
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

BIN
ActionTowerDefense/Assets/NuGet/README.pdf


+ 8 - 0
ActionTowerDefense/Assets/NuGet/README.pdf.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 83c5d2001771f15429a88d67e81366d6
+timeCreated: 1517876157
+licenseType: Free
+DefaultImporter:
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 9 - 0
ActionTowerDefense/Assets/NuGet/Resources.meta

@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: 1738075a39a390447b7a620ca6962142
+folderAsset: yes
+timeCreated: 1510280362
+licenseType: Free
+DefaultImporter:
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

BIN
ActionTowerDefense/Assets/NuGet/Resources/defaultIcon.png


+ 88 - 0
ActionTowerDefense/Assets/NuGet/Resources/defaultIcon.png.meta

@@ -0,0 +1,88 @@
+fileFormatVersion: 2
+guid: eec19781926cd2248b7c9abfde8db555
+TextureImporter:
+  fileIDToRecycleName: {}
+  externalObjects: {}
+  serializedVersion: 9
+  mipmaps:
+    mipMapMode: 0
+    enableMipMap: 1
+    sRGBTexture: 1
+    linearTexture: 0
+    fadeOut: 0
+    borderMipMap: 0
+    mipMapsPreserveCoverage: 0
+    alphaTestReferenceValue: 0.5
+    mipMapFadeDistanceStart: 1
+    mipMapFadeDistanceEnd: 3
+  bumpmap:
+    convertToNormalMap: 0
+    externalNormalMap: 0
+    heightScale: 0.25
+    normalMapFilter: 0
+  isReadable: 0
+  streamingMipmaps: 0
+  streamingMipmapsPriority: 0
+  grayScaleToAlpha: 0
+  generateCubemap: 6
+  cubemapConvolution: 0
+  seamlessCubemap: 0
+  textureFormat: -1
+  maxTextureSize: 2048
+  textureSettings:
+    serializedVersion: 2
+    filterMode: -1
+    aniso: -1
+    mipBias: -100
+    wrapU: 1
+    wrapV: 1
+    wrapW: 1
+  nPOTScale: 0
+  lightmap: 0
+  compressionQuality: 50
+  spriteMode: 1
+  spriteExtrude: 1
+  spriteMeshType: 1
+  alignment: 0
+  spritePivot: {x: 0.5, y: 0.5}
+  spritePixelsToUnits: 100
+  spriteBorder: {x: 0, y: 0, z: 0, w: 0}
+  spriteGenerateFallbackPhysicsShape: 1
+  alphaUsage: 1
+  alphaIsTransparency: 1
+  spriteTessellationDetail: -1
+  textureType: 8
+  textureShape: 1
+  singleChannelComponent: 0
+  maxTextureSizeSet: 0
+  compressionQualitySet: 0
+  textureFormatSet: 0
+  platformSettings:
+  - serializedVersion: 2
+    buildTarget: DefaultTexturePlatform
+    maxTextureSize: 2048
+    resizeAlgorithm: 0
+    textureFormat: -1
+    textureCompression: 1
+    compressionQuality: 50
+    crunchedCompression: 0
+    allowsAlphaSplitting: 0
+    overridden: 0
+    androidETC2FallbackOverride: 0
+  spriteSheet:
+    serializedVersion: 2
+    sprites: []
+    outline: []
+    physicsShape: []
+    bones: []
+    spriteID: 215e43cda847e6d44af8b40376eeed8a
+    vertices: []
+    indices: 
+    edges: []
+    weights: []
+  spritePackingTag: 
+  pSDRemoveMatte: 0
+  pSDShowRemoveMatteOption: 0
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

BIN
ActionTowerDefense/Assets/Plugins/EPPlus.dll


+ 33 - 0
ActionTowerDefense/Assets/Plugins/EPPlus.dll.meta

@@ -0,0 +1,33 @@
+fileFormatVersion: 2
+guid: cb5865dce1c6ee24ba3768bfeac9efdf
+PluginImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  iconMap: {}
+  executionOrder: {}
+  defineConstraints: []
+  isPreloaded: 0
+  isOverridable: 0
+  isExplicitlyReferenced: 0
+  validateReferences: 1
+  platformData:
+  - first:
+      Any: 
+    second:
+      enabled: 1
+      settings: {}
+  - first:
+      Editor: Editor
+    second:
+      enabled: 0
+      settings:
+        DefaultValueInitialized: true
+  - first:
+      Windows Store Apps: WindowsStoreApps
+    second:
+      enabled: 0
+      settings:
+        CPU: AnyCPU
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 46 - 0
ActionTowerDefense/Assets/Scripts/ExcelEditor.cs

@@ -0,0 +1,46 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using OfficeOpenXml;
+using System.IO;
+
+public class ExcelEditor
+{
+    //获取所有Sheet名称
+	public static List<string> ReadExcelSheetsInfo(string filePath)
+	{
+		FileInfo fileInfo = new FileInfo(filePath);
+		using (ExcelPackage package = new ExcelPackage(fileInfo))
+		{
+			// 获取Sheet数量
+			int sheetCount = package.Workbook.Worksheets.Count;
+			// 获取所有Sheet名称
+			List<string> sheetNames = new List<string>();
+			foreach (ExcelWorksheet worksheet in package.Workbook.Worksheets)
+			{
+				sheetNames.Add(worksheet.Name);
+			}
+			return sheetNames;
+		}
+	}
+
+    //修改Sheet名称
+    public static void RenameSheet(string filePath, string oldSheetName, string newSheetName)
+    {
+        FileInfo fileInfo = new FileInfo(filePath);
+
+        using (ExcelPackage package = new ExcelPackage(fileInfo))
+        {
+            ExcelWorksheet worksheet = package.Workbook.Worksheets[oldSheetName];
+            if (worksheet != null)
+            {
+                worksheet.Name = newSheetName;
+                package.Save();
+            }
+            else
+            {
+                Debug.LogError($"Sheet '{oldSheetName}' not found in the Excel file.");
+            }
+        }
+    }
+}

+ 11 - 0
ActionTowerDefense/Assets/Scripts/ExcelEditor.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 09ebfa70324ff6b41b4e7ea727c39077
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

BIN
ActionTowerDefense/Luban/Config/Datas/出怪表.xlsx