/// <summary> /// Draws the data fields for each operation /// </summary> /// <param name="op"></param> public static void DrawOperationFields(GaiaOperation op, EditorUtils editorUtils, GaiaSessionManager sessionManager, bool helpEnabled, int currentIndex) { //shared default fields first //op.m_isActive = m_editorUtils.Toggle("Active", op.m_isActive, helpEnabled); bool currentGUIState = GUI.enabled; GUI.enabled = op.m_isActive; op.m_description = editorUtils.TextField("Description", op.m_description, helpEnabled); editorUtils.LabelField("DateTime", new GUIContent(op.m_operationDateTime), helpEnabled); EditorGUI.indentLevel++; op.m_terrainsFoldedOut = editorUtils.Foldout(op.m_terrainsFoldedOut, "AffectedTerrains", helpEnabled); if (op.m_terrainsFoldedOut) { foreach (string name in op.m_affectedTerrainNames) { EditorGUILayout.LabelField(name); } } EditorGUI.indentLevel--; //type specific fields, switch by op type to draw additional fields suitable for the op type switch (op.m_operationType) { case GaiaOperation.OperationType.CreateWorld: editorUtils.LabelField("xTiles", new GUIContent(op.WorldCreationSettings.m_xTiles.ToString()), helpEnabled); editorUtils.LabelField("zTiles", new GUIContent(op.WorldCreationSettings.m_zTiles.ToString()), helpEnabled); editorUtils.LabelField("TileSize", new GUIContent(op.WorldCreationSettings.m_tileSize.ToString()), helpEnabled); break; case GaiaOperation.OperationType.Spawn: editorUtils.LabelField("NumberOfSpawners", new GUIContent(op.SpawnOperationSettings.m_spawnerSettingsList.Count.ToString()), helpEnabled); float size = (float)Mathd.Max(op.SpawnOperationSettings.m_spawnArea.size.x, op.SpawnOperationSettings.m_spawnArea.size.z); editorUtils.LabelField("SpawnSize", new GUIContent(size.ToString()), helpEnabled); break; } GUI.enabled = currentGUIState; //Button controls EditorGUILayout.BeginHorizontal(); GUILayout.Space(20); if (editorUtils.Button("Delete")) { if (EditorUtility.DisplayDialog(editorUtils.GetTextValue("PopupDeleteTitle"), editorUtils.GetTextValue("PopupDeleteText"), editorUtils.GetTextValue("OK"), editorUtils.GetTextValue("Cancel"))) { try { if (!String.IsNullOrEmpty(op.scriptableObjectAssetGUID)) { AssetDatabase.DeleteAsset(AssetDatabase.GUIDToAssetPath(op.scriptableObjectAssetGUID)); } } catch (Exception ex) { Debug.LogError("Error while deleting one of the operation data files: " + ex.Message + " Stack Trace:" + ex.StackTrace); } sessionManager.RemoveOperation(currentIndex); EditorGUIUtility.ExitGUI(); } } GUI.enabled = op.m_isActive; if (editorUtils.Button("Play")) { if (EditorUtility.DisplayDialog(editorUtils.GetTextValue("PopupPlayTitle"), editorUtils.GetTextValue("PopupPlayText"), editorUtils.GetTextValue("OK"), editorUtils.GetTextValue("Cancel"))) { GaiaSessionManager.ExecuteOperation(op); //Destroy all temporary tools used while executing //not if it is a spawn operation since that is asynchronous if (op.m_operationType != GaiaOperation.OperationType.Spawn) { GaiaSessionManager.DestroyTempSessionTools(); } } } GUI.enabled = currentGUIState; //EditorGUILayout.EndHorizontal(); //EditorGUILayout.BeginHorizontal(); //GUILayout.Space(20); if (editorUtils.Button("ViewData")) { switch (op.m_operationType) { case GaiaOperation.OperationType.CreateWorld: Selection.activeObject = op.WorldCreationSettings; break; case GaiaOperation.OperationType.Stamp: Selection.activeObject = op.StamperSettings; break; case GaiaOperation.OperationType.Spawn: Selection.activeObject = op.SpawnOperationSettings; break; case GaiaOperation.OperationType.FlattenTerrain: Selection.activeObject = op.FlattenOperationSettings; break; case GaiaOperation.OperationType.StampUndo: Selection.activeObject = op.UndoRedoOperationSettings; break; case GaiaOperation.OperationType.StampRedo: Selection.activeObject = op.UndoRedoOperationSettings; break; case GaiaOperation.OperationType.ClearSpawns: Selection.activeObject = op.ClearOperationSettings; break; case GaiaOperation.OperationType.RemoveNonBiomeResources: Selection.activeObject = op.RemoveNonBiomeResourcesSettings; break; case GaiaOperation.OperationType.MaskMapExport: Selection.activeObject = op.ExportMaskMapOperationSettings; break; } EditorGUIUtility.PingObject(Selection.activeObject); } switch (op.m_operationType) { case GaiaOperation.OperationType.Stamp: if (editorUtils.Button("PreviewInStamper")) { Stamper stamper = GaiaSessionManager.GetOrCreateSessionStamper(); stamper.LoadSettings(op.StamperSettings); #if GAIA_PRO_PRESENT if (GaiaUtils.HasDynamicLoadedTerrains()) { //We got placeholders, activate terrain loading stamper.m_loadTerrainMode = LoadMode.EditorSelected; } #endif Selection.activeObject = stamper.gameObject; } break; case GaiaOperation.OperationType.Spawn: if (editorUtils.Button("PreviewInSpawner")) { BiomeController bmc = null; List <Spawner> spawnerList = null; Selection.activeObject = GaiaSessionManager.GetOrCreateSessionSpawners(op.SpawnOperationSettings, ref bmc, ref spawnerList); } break; case GaiaOperation.OperationType.MaskMapExport: #if GAIA_PRO_PRESENT if (editorUtils.Button("PreviewInExport")) { MaskMapExport mme = null; Selection.activeObject = GaiaSessionManager.GetOrCreateMaskMapExporter(op.ExportMaskMapOperationSettings.m_maskMapExportSettings, ref mme); } #endif break; } EditorGUILayout.EndHorizontal(); }