Parcourir la source

修复点击塔数据不会变的问题

wgl il y a 5 mois
Parent
commit
94d245f35f

+ 6 - 10
ActionTowerDefense/Assets/GameLevelEditor/GameMap/CoreScripts/Editor/GameMapEditor.cs

@@ -24,6 +24,7 @@ public class GameMapEditor : EditorWindow
 	private static bool showMapProperties = true;
 	private static bool showTileProperties = true;
     private static bool showLayers = true;
+	public bool haveChangeGrid;
     private static GameMapEdPopup mapsPopup = new GameMapEdPopup();
 	private static Vector2[] scroll = { Vector2.zero, Vector2.zero };
 
@@ -993,6 +994,7 @@ public class GameMapEditor : EditorWindow
 					newSpawnTimes.Add(spawnTime);
                 }
 			}
+			
             if (newSpawnTimes.Count >= 1)
             {
 				for(int i = 0; i < newSpawnTimes.Count; i++)
@@ -1029,15 +1031,10 @@ public class GameMapEditor : EditorWindow
 		EditorGUILayout.EndVertical();
 
 
-		if (EditorGUI.EndChangeCheck())
+		if (EditorGUI.EndChangeCheck() || haveChangeGrid)
 		{
 			Undo.RecordObject(asset, "Change Layer Information");
-			//foreach (GameMapTile tile in asset.tileAsset.tiles)
-			//{
-			//	SpawnTimeList spawnTimeList = tile.spawnTime[currLayer];
-			//	spawnTimeList.curLayer = addName;
-			//	tile.spawnTime[currLayer] = spawnTimeList;
-			//}
+			haveChangeGrid = false;
 			layer.name = addName;
 			layer.isFromTower = isFromTower;
 			layer.duration = duration;
@@ -1048,7 +1045,6 @@ public class GameMapEditor : EditorWindow
 			AssetDatabase.SaveAssets();
 		}
 		// 标记资源为脏数据,以便保存更改
-
 		// 显示其他图层信息(根据需求扩展)
 		//EditorGUILayout.LabelField("Other Properties:");
 		//EditorGUILayout.LabelField($"Grid Size: {layer.gridSize}");
@@ -1824,8 +1820,8 @@ public class GameMapEditor : EditorWindow
 
 	private void GridClick(Rect mainRect, GameMap map, Event ev)
 	{
-		
-        int[] grid = (currLayer < 0 ? map.grid : map.layers[currLayer].grid);
+		haveChangeGrid = true;
+		int[] grid = (currLayer < 0 ? map.grid : map.layers[currLayer].grid);
         int idx = MousePosToGridIdx(map, ev);
 		if (ev.modifiers == EventModifiers.Shift && ev.button == 0)
 		{   // mark tiles in grid