public void DrawEditor() { UnityEngine.GUI.color = Color.cyan; if (GUILayout.Button("\nLoad Paths\n")) { foreach (PathEditor pathEditor in PathEditors) { GameObject.DestroyImmediate(pathEditor.gameObject); } PathEditors.Clear(); LoadedPaths.Clear(); ChunkTransforms.Clear(); if (!Manager.IsAwake <Mods> ()) { Manager.WakeUp <Mods> ("__MODS"); } Mods.Get.Editor.InitializeEditor(true); ChunkParentTransform = gameObject.FindOrCreateChild("Chunks"); PathParentTransform = gameObject.FindOrCreateChild("Paths"); List <string> chunkNames = Mods.Get.ModDataNames("Chunk"); foreach (string chunkName in chunkNames) { ChunkState chunkState = null; if (Mods.Get.Runtime.LoadMod <ChunkState> (ref chunkState, "Chunk", chunkName)) { GameObject newChunkGameObject = ChunkParentTransform.gameObject.FindOrCreateChild(chunkState.ID.ToString()).gameObject; //look up the chunk terrain data and apply the offset Vector3 chunkPosition = chunkState.TileOffset; //chunkPosition.y = chunkState.YOffset; newChunkGameObject.transform.position = chunkPosition; //we'll use the ID for looking up path chunks later ChunkTransforms.Add(newChunkGameObject.transform); //now look for any terrain GameObject terrainObject = GameObject.Find(chunkState.XTilePosition.ToString() + " " + chunkState.ZTilePosition.ToString()); if (terrainObject != null) { terrainObject.transform.parent = newChunkGameObject.transform; terrainObject.transform.ResetLocal(); Terrain terrain = terrainObject.GetComponent <Terrain> (); terrain.heightmapPixelError = 50; } } } Mods.Get.Editor.LoadAvailableMods <Path> (LoadedPaths, "Path"); foreach (Path path in LoadedPaths) { GameObject pathEditorGameObject = PathParentTransform.gameObject.FindOrCreateChild(path.Name).gameObject; PathEditor pathEditor = pathEditorGameObject.GetOrAdd <PathEditor> (); pathEditor.DoNotRefreshOrSave = false; pathEditor.Name = path.Name; pathEditor.State = path; pathEditor.EditorRefresh(); pathEditor.BuildSpline(); } MergeOverlappingTemplates(); } if (GUILayout.Button("\nSnap Nearby Templates\n")) { SnapNearbyTemplates(); MergeOverlappingTemplates(); } if (GUILayout.Button("\nMinimum Height\n")) { AdjustMinimumHeight(); } if (GUILayout.Button("\nRefreshAll\n")) { foreach (PathEditor pe in PathEditors) { Debug.Log(pe.Name); pe.EditorRefresh(); } } if (GUILayout.Button("\nSave Paths\n")) { PathEditors.Clear(); PathEditors.AddRange(PathParentTransform.GetComponentsInChildren <PathEditor> ()); foreach (PathEditor editor in PathEditors) { editor.EditorSave(); } } }