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(); } } }
public void DrawEditor() { if (WorldItems.Get == null) { Manager.WakeUp <WorldItems>("Frontiers_WorldItems"); WorldItems.Get.Initialize(); } GUILayout.Label("Blueprint categories:"); if (openWindow) { SelectWorldItem(); } UnityEngine.GUI.color = Color.cyan; if (!string.IsNullOrEmpty(selectedCategory)) { GUILayout.Label("Selected category: " + selectedCategory); List <WIBlueprint> blueprintList = BlueprintsByCategory(selectedCategory); foreach (WIBlueprint blueprint in blueprintList) { // GUILayout.BeginHorizontal ( ); UnityEngine.GUI.color = Color.yellow; if (blueprint == selectedBlueprint) { UnityEngine.GUI.color = Color.cyan; GUILayout.Label("Selected blueprint:"); GUILayout.BeginHorizontal(); if (blueprint.GenericResult != null && !string.IsNullOrEmpty(blueprint.GenericResult.PrefabName)) { if (GUILayout.Button(blueprint.GenericResult.PrefabName)) { rowSelection = null; rowIndex = 100; openWindow = true; } } else { if (GUILayout.Button("(Choose result)")) { rowSelection = null; rowIndex = 100; openWindow = true; } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Name:"); blueprint.Name = GUILayout.TextField(blueprint.Name); if (string.IsNullOrEmpty(blueprint.Name)) { if (!blueprint.GenericResult.IsEmpty) { blueprint.Name = blueprint.GenericResult.PrefabName; } } GUILayout.Label("Required Skill:"); blueprint.RequiredSkill = GUILayout.TextField(blueprint.RequiredSkill); GUILayout.Label("Title:"); blueprint.Title = GUILayout.TextField(blueprint.Title); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); blueprint.Revealed = GUILayout.Toggle(blueprint.Revealed, "Revealed"); blueprint.UseGenericResult = GUILayout.Toggle(blueprint.UseGenericResult, "Generic Result"); blueprint.BaseCraftTime = UnityEditor.EditorGUILayout.FloatField(blueprint.BaseCraftTime); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Row 1:"); for (int i = 0; i < selectedBlueprint.Row1.Count; i++) { if (i == rowIndex && selectedBlueprint.Row1 == rowSelection) { UnityEngine.GUI.color = Color.yellow; } else { UnityEngine.GUI.color = Color.white; } if (selectedBlueprint.Row1[i] == null || selectedBlueprint.Row1[i].StackName == string.Empty) { UnityEngine.GUI.color = Color.Lerp(UnityEngine.GUI.color, Color.gray, 0.5f); if (GUILayout.Button("\n\n -(Empty)= \n\n")) { rowSelection = selectedBlueprint.Row1; rowIndex = i; openWindow = true; } } else { UnityEngine.GUI.color = Color.Lerp(UnityEngine.GUI.color, Color.gray, 0.5f); if (GUILayout.Button("\n\n" + selectedBlueprint.Row1[i].StackName + "\n\n")) { rowSelection = selectedBlueprint.Row1; rowIndex = i; openWindow = true; } } } GUILayout.EndHorizontal(); UnityEngine.GUI.color = Color.cyan; GUILayout.BeginHorizontal(); GUILayout.Label("Row 2:"); for (int i = 0; i < selectedBlueprint.Row2.Count; i++) { if (i == rowIndex && selectedBlueprint.Row2 == rowSelection) { UnityEngine.GUI.color = Color.yellow; } else { UnityEngine.GUI.color = Color.white; } if (selectedBlueprint.Row2[i] == null || selectedBlueprint.Row2[i].StackName == string.Empty) { UnityEngine.GUI.color = Color.Lerp(UnityEngine.GUI.color, Color.gray, 0.5f); if (GUILayout.Button("\n\n -(Empty)= \n\n")) { rowSelection = selectedBlueprint.Row2; rowIndex = i; openWindow = true; } } else { UnityEngine.GUI.color = Color.Lerp(UnityEngine.GUI.color, Color.white, 0.5f); if (GUILayout.Button("\n\n" + selectedBlueprint.Row2[i].StackName + "\n\n")) { rowSelection = selectedBlueprint.Row2; rowIndex = i; openWindow = true; } } } GUILayout.EndHorizontal(); UnityEngine.GUI.color = Color.cyan; GUILayout.BeginHorizontal(); GUILayout.Label("Row 3:"); for (int i = 0; i < selectedBlueprint.Row3.Count; i++) { if (i == rowIndex && selectedBlueprint.Row3 == rowSelection) { UnityEngine.GUI.color = Color.yellow; } else { UnityEngine.GUI.color = Color.white; } if (selectedBlueprint.Row3[i] == null || selectedBlueprint.Row3[i].StackName == string.Empty) { UnityEngine.GUI.color = Color.Lerp(UnityEngine.GUI.color, Color.gray, 0.5f); if (GUILayout.Button("\n\n -(Empty)= \n\n")) { rowSelection = selectedBlueprint.Row3; rowIndex = i; openWindow = true; } } else { UnityEngine.GUI.color = Color.Lerp(UnityEngine.GUI.color, Color.white, 0.5f); if (GUILayout.Button("\n\n" + selectedBlueprint.Row3[i].StackName + "\n\n")) { rowSelection = selectedBlueprint.Row3; rowIndex = i; openWindow = true; } } } GUILayout.EndHorizontal(); } else { if (blueprint.GenericResult != null) { if (GUILayout.Button(blueprint.GenericResult.StackName)) { selectedBlueprint = blueprint; } } else { if (GUILayout.Button(" (empty blueprint) ")) { selectedBlueprint = blueprint; } } } } UnityEngine.GUI.color = Color.cyan; GUILayout.BeginHorizontal(); GUILayout.Label(" "); if (GUILayout.Button("Create blueprint")) { EditorCreateBlueprint("New blueprint", selectedCategory); } GUILayout.Label(" "); GUILayout.EndHorizontal(); if (GUILayout.Button("\nTOP\n")) { selectedCategory = null; } } else { UnityEngine.GUI.color = Color.cyan; if (GUILayout.Button("\nTOP\n")) { selectedCategory = null; } else { UnityEngine.GUI.color = Color.cyan; foreach (string category in Categories) { if (GUILayout.Button(category)) { selectedCategory = category; return; } } } } UnityEngine.GUI.color = Color.yellow; if (GUILayout.Button("\n SAVE TO DISK \n")) { SaveBlueprintsEditor(); } if (GUILayout.Button("\n LOAD FROM DISK \n")) { LoadBlueprintsEditor(); } }