Browse Source

修复gui组件报错

wgl 7 tháng trước cách đây
mục cha
commit
26756aa12e

+ 26 - 5
ActionTowerDefense/Assets/GameLevelEditor/GameMap/CoreScripts/Editor/GameMapEditor.cs

@@ -889,8 +889,8 @@ public class GameMapEditor : EditorWindow
 					newSpawnTimes.Add(spawnTime);
                 }
 			}
-			
-            for (int i = 0; i < spawnTimes.Count; i++)
+
+			for (int i = 0; i < spawnTimes.Count; i++)
             {
 				SpawnTime spawnTime = spawnTimes[i];
 				if (newSpawnTimes.Exists(x => x.id == spawnTime.id))
@@ -898,7 +898,7 @@ public class GameMapEditor : EditorWindow
 					SpawnTime newSpawnTime = newSpawnTimes.First(x => x.id == spawnTime.id);
 					spawnTime.id = newSpawnTime.id;
 					spawnTime.pos = newSpawnTime.pos;
-
+					
 					EditorGUILayout.LabelField($"{asset.tileAsset.GetTile(spawnTime.id).name} - {spawnTime.pos.Count}", EditorStyles.boldLabel);
 					spawnTime.startTime = EditorGUILayout.IntField("Start Time", spawnTime.startTime);
 					spawnTime.endTime = EditorGUILayout.IntField("End Time", spawnTime.endTime);
@@ -911,12 +911,14 @@ public class GameMapEditor : EditorWindow
 							layer.grid[spawnTime.pos[j]] = -1;
 						}
 						spawnTimes.RemoveAt(i);
+						i--;
 					}
 					newSpawnTimes.Remove(newSpawnTime);
                 }
                 else
                 {
 					spawnTimes.RemoveAt(i);
+					i--;
 				}
             }
             if (newSpawnTimes.Count >= 1)
@@ -924,8 +926,27 @@ public class GameMapEditor : EditorWindow
 				for(int i = 0; i < newSpawnTimes.Count; i++)
                 {
 					SpawnTime newSpawnTime = newSpawnTimes[i];
-					spawnTimes.Add(newSpawnTime);
-                }
+					
+					EditorGUILayout.LabelField($"{asset.tileAsset.GetTile(newSpawnTime.id).name} - {newSpawnTime.pos.Count}", EditorStyles.boldLabel);
+					newSpawnTime.startTime = EditorGUILayout.IntField("Start Time", newSpawnTime.startTime);
+					newSpawnTime.endTime = EditorGUILayout.IntField("End Time", newSpawnTime.endTime);
+					newSpawnTime.num = EditorGUILayout.IntField("Number", newSpawnTime.num);
+
+					bool isRemove = false;
+					if (GUILayout.Button("Remove"))
+					{
+						for (int j = 0; j < newSpawnTime.pos.Count; j++)
+						{
+							layer.grid[newSpawnTime.pos[j]] = -1;
+						}
+						isRemove = true;
+					}
+                    if (!isRemove)
+                    {
+						spawnTimes.Add(newSpawnTime);
+					}
+					
+				}
             }