Exemple #1
0
        private void DrawStopwatchEvent(GaiaStopWatchEvent stopWatchEvent)
        {
            int id = m_gaiastopwatchDataset.m_events.FindIndex(x => x == stopWatchEvent);

            m_unfoldedStates[id] = m_editorUtils.Foldout(m_unfoldedStates[id], new GUIContent(stopWatchEvent.m_name));
            if (m_unfoldedStates[id])
            {
                EditorGUI.indentLevel++;
                m_editorUtils.LabelField("FirstStart", new GUIContent(stopWatchEvent.m_firstStartTimeStamp.ToString()));
                m_editorUtils.LabelField("TotalDuration", new GUIContent(stopWatchEvent.m_accumulatedTime.ToString()));
                m_editorUtils.LabelField("Calls", new GUIContent(stopWatchEvent.m_callCount.ToString()));
                m_editorUtils.LabelField("DurationPerCall", new GUIContent(stopWatchEvent.m_durationPerCall.ToString()));


                List <GaiaStopWatchEvent> relevantEvents;

                if (m_orderbyDescending)
                {
                    relevantEvents = m_gaiastopwatchDataset.m_events.FindAll(x => x.m_parent == stopWatchEvent.m_name).OrderByDescending(m_orderByLambda).ToList();
                }
                else
                {
                    relevantEvents = m_gaiastopwatchDataset.m_events.FindAll(x => x.m_parent == stopWatchEvent.m_name).OrderBy(m_orderByLambda).ToList();
                }

                foreach (GaiaStopWatchEvent subEvent in relevantEvents)
                {
                    DrawStopwatchEvent(subEvent);
                }
                EditorGUI.indentLevel--;
            }
        }
Exemple #2
0
        /// <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();
        }
Exemple #3
0
        private void DrawOperations(bool helpEnabled)
        {
            if (m_manager.m_session == null)
            {
                return;
            }
            if (m_manager.m_session.m_operations.Count > 0)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(8);
                bool oldSelectAll = m_manager.m_selectAllOperations;
                m_manager.m_selectAllOperations = m_editorUtils.Toggle(m_manager.m_selectAllOperations, m_editorUtils.GetContent("SelectAllToolTip"));

                if (m_manager.m_selectAllOperations != oldSelectAll)
                {
                    foreach (GaiaOperation op in m_manager.m_session.m_operations)
                    {
                        op.m_isActive = m_manager.m_selectAllOperations;
                    }
                }
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            }
            else
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(50);
                GUILayout.FlexibleSpace();
                m_editorUtils.Text("NoOperationsYet");
                GUILayout.FlexibleSpace();
                GUILayout.Space(50);
                GUILayout.EndHorizontal();
            }
            //Extra indent needed to draw the foldouts in the correct position
            EditorGUI.indentLevel++;
            bool currentGUIState = GUI.enabled;

            for (int i = 0; i < m_manager.m_session.m_operations.Count; i++)
            {
                GaiaOperation op          = m_manager.m_session.m_operations[i];
                GUIStyle      headerStyle = m_operationCreateWorldStyle;

                switch (op.m_operationType)
                {
                case GaiaOperation.OperationType.CreateWorld:
                    headerStyle = m_operationCreateWorldStyle;
                    break;

                case GaiaOperation.OperationType.ClearSpawns:
                    headerStyle = m_operationClearSpawnsStyle;
                    break;

                case GaiaOperation.OperationType.FlattenTerrain:
                    headerStyle = m_operationFlattenTerrainStyle;
                    break;

                case GaiaOperation.OperationType.RemoveNonBiomeResources:
                    headerStyle = m_operationRemoveNonBiomeResourcesStyle;
                    break;

                case GaiaOperation.OperationType.Spawn:
                    headerStyle = m_operationSpawnStyle;
                    break;

                case GaiaOperation.OperationType.Stamp:
                    headerStyle = m_operationStampStyle;
                    break;

                case GaiaOperation.OperationType.StampUndo:
                    headerStyle = m_operationStampUndoRedoStyle;
                    break;

                case GaiaOperation.OperationType.StampRedo:
                    headerStyle = m_operationStampUndoRedoStyle;
                    break;

                case GaiaOperation.OperationType.MaskMapExport:
                    headerStyle = m_operationMaskMapExportStyle;
                    break;
                }
                GUI.enabled = op.m_isActive;
                GUILayout.BeginHorizontal(headerStyle);
                GUI.enabled      = currentGUIState;
                op.m_isActive    = GUILayout.Toggle(op.m_isActive, "", m_operationCheckboxStyle);
                GUI.enabled      = op.m_isActive;
                op.m_isFoldedOut = m_editorUtils.Foldout(op.m_isFoldedOut, new GUIContent((i + 1).ToString() + " " + op.m_description.ToString()), true, m_operationFoldOutStyle);
                GUILayout.EndHorizontal();
                GUI.enabled = currentGUIState;

                if (op.m_isFoldedOut)
                {
                    DrawOperationFields(op, m_editorUtils, m_manager, helpEnabled, i);
                }
                GUILayout.Space(2);
            }
            EditorGUI.indentLevel--;
        }
Exemple #4
0
        private void DrawTerrains(bool helpEnabled)
        {
            bool originalGUIState = GUI.enabled;

#if GAIA_PRO_PRESENT
            EditorGUILayout.BeginHorizontal();
            m_editorUtils.Label("IngestTerrain", GUILayout.Width(100));
            m_ingestTerrain = (Terrain)EditorGUILayout.ObjectField(m_ingestTerrain, typeof(Terrain), true);
            if (m_editorUtils.Button("Ingest"))
            {
                ////Try to find the X and Z coordinate for the scene name
                //double minX = m_terrainLoaderManager.TerrainSceneStorage.m_terrainScenes.Select(x => x.m_pos.x).Min();
                //double maxX = m_terrainLoaderManager.TerrainSceneStorage.m_terrainScenes.Select(x => x.m_pos.x).Max();
                //double minZ = m_terrainLoaderManager.TerrainSceneStorage.m_terrainScenes.Select(x => x.m_pos.z).Min();
                //double maxZ = m_terrainLoaderManager.TerrainSceneStorage.m_terrainScenes.Select(x => x.m_pos.z).Max();
                GaiaSessionManager    sessionManager        = GaiaSessionManager.GetSessionManager();
                WorldCreationSettings worldCreationSettings = new WorldCreationSettings()
                {
                    m_autoUnloadScenes      = false,
                    m_applyFloatingPointFix = TerrainLoaderManager.Instance.TerrainSceneStorage.m_useFloatingPointFix,
                    m_isWorldMap            = false
                };
                TerrainScene newScene = TerrainSceneCreator.CreateTerrainScene(m_ingestTerrain.gameObject.scene, TerrainLoaderManager.Instance.TerrainSceneStorage, sessionManager.m_session, m_ingestTerrain.gameObject, worldCreationSettings);
                TerrainLoaderManager.Instance.TerrainSceneStorage.m_terrainScenes.Add(newScene);
                TerrainLoaderManager.Instance.SaveStorageData();
                GaiaSessionManager.AddTerrainScenesToBuildSettings(new List <TerrainScene>()
                {
                    newScene
                });
            }
            EditorGUILayout.EndHorizontal();
            GUILayout.Space(EditorGUIUtility.singleLineHeight);
#endif

            EditorGUILayout.BeginHorizontal();
            if (m_editorUtils.Button("AddToBuildSettings"))
            {
                if (TerrainLoaderManager.ColliderOnlyLoadingActive)
                {
                    if (EditorUtility.DisplayDialog(m_editorUtils.GetTextValue("AddColliderScenesToBuildSettingsPopupTitle"), m_editorUtils.GetTextValue("AddColliderScenesToBuildSettingsPopupText"), m_editorUtils.GetTextValue("Continue"), m_editorUtils.GetTextValue("Cancel")))
                    {
#if GAIA_PRO_PRESENT
                        GaiaSessionManager.AddOnlyColliderScenesToBuildSettings(m_terrainLoaderManager.TerrainSceneStorage.m_terrainScenes);
#endif
                    }
                }
                else
                {
                    if (EditorUtility.DisplayDialog(m_editorUtils.GetTextValue("AddToBuildSettingsPopupTitle"), m_editorUtils.GetTextValue("AddToBuildSettingsPopupText"), m_editorUtils.GetTextValue("Continue"), m_editorUtils.GetTextValue("Cancel")))
                    {
#if GAIA_PRO_PRESENT
                        GaiaSessionManager.AddTerrainScenesToBuildSettings(m_terrainLoaderManager.TerrainSceneStorage.m_terrainScenes);
#endif
                    }
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            if (m_editorUtils.Button("UnloadAll"))
            {
                m_terrainLoaderManager.SetLoadingRange(0, 0);
                m_terrainLoaderManager.UnloadAll(true);
            }
            if (m_editorUtils.Button("LoadAll"))
            {
                if (EditorUtility.DisplayDialog(m_editorUtils.GetTextValue("LoadAllPopupTitle"), m_editorUtils.GetTextValue("LoadAllPopupText"), m_editorUtils.GetTextValue("Continue"), m_editorUtils.GetTextValue("Cancel")))
                {
                    foreach (TerrainScene terrainScene in m_terrainLoaderManager.TerrainSceneStorage.m_terrainScenes)
                    {
                        m_terrainLoaderManager.SetLoadingRange(100000, m_terrainLoaderManager.GetImpostorLoadingRange());
                        terrainScene.AddRegularReference(m_terrainLoaderManager.gameObject);
                    }
                }
            }

            EditorGUILayout.EndHorizontal();

            if (!GaiaUtils.HasImpostorTerrains())
            {
                GUI.enabled = false;
            }
            EditorGUILayout.BeginHorizontal();
            if (m_editorUtils.Button("UnloadAllImpostors"))
            {
                m_terrainLoaderManager.SetLoadingRange(m_terrainLoaderManager.GetLoadingRange(), 0);
                m_terrainLoaderManager.UnloadAllImpostors(true);
            }
            if (m_editorUtils.Button("LoadAllImpostors"))
            {
                if (EditorUtility.DisplayDialog(m_editorUtils.GetTextValue("LoadAllPopupTitle"), m_editorUtils.GetTextValue("LoadAllImpostorsPopupText"), m_editorUtils.GetTextValue("Continue"), m_editorUtils.GetTextValue("Cancel")))
                {
                    m_terrainLoaderManager.SetLoadingRange(m_terrainLoaderManager.GetLoadingRange(), 100000);
                    foreach (TerrainScene terrainScene in m_terrainLoaderManager.TerrainSceneStorage.m_terrainScenes)
                    {
                        terrainScene.AddImpostorReference(m_terrainLoaderManager.gameObject);
                    }
                }
            }

            EditorGUILayout.EndHorizontal();

            GUI.enabled = originalGUIState;

            GUILayout.Space(EditorGUIUtility.singleLineHeight);

            float buttonWidth1 = 110;
            float buttonWidth2 = 60;

            if (m_terrainBoxStyle == null || m_terrainBoxStyle.normal.background == null)
            {
                m_terrainBoxStyle         = new GUIStyle(EditorStyles.helpBox);
                m_terrainBoxStyle.margin  = new RectOffset(0, 0, 0, 0);
                m_terrainBoxStyle.padding = new RectOffset(3, 3, 3, 3);
            }

            int removeIndex  = -99;
            int currentIndex = 0;

            foreach (TerrainScene terrainScene in m_terrainLoaderManager.TerrainSceneStorage.m_terrainScenes)
            {
                EditorGUILayout.BeginVertical(m_terrainBoxStyle);
                {
                    EditorGUILayout.LabelField(terrainScene.GetTerrainName());
                    EditorGUILayout.BeginHorizontal();
                    bool isLoaded         = terrainScene.m_regularLoadState == LoadState.Loaded && terrainScene.TerrainObj != null && terrainScene.TerrainObj.activeInHierarchy;
                    bool isImpostorLoaded = terrainScene.m_impostorLoadState == LoadState.Loaded || terrainScene.m_impostorLoadState == LoadState.Cached;

                    bool currentGUIState = GUI.enabled;
                    GUI.enabled = isLoaded;
                    if (m_editorUtils.Button("SelectPlaceholder", GUILayout.Width(buttonWidth1)))
                    {
                        Selection.activeGameObject = GameObject.Find(terrainScene.GetTerrainName());
                        EditorGUIUtility.PingObject(Selection.activeObject);
                    }
                    GUI.enabled = currentGUIState;
                    if (isLoaded)
                    {
                        if (m_editorUtils.Button("UnloadPlaceholder", GUILayout.Width(buttonWidth2)))
                        {
                            if (ResetToWorldOriginLoading())
                            {
                                terrainScene.RemoveAllReferences(true);
                            }
                        }
                    }
                    else
                    {
                        if (m_editorUtils.Button("LoadPlaceholder", GUILayout.Width(buttonWidth2)))
                        {
                            if (ResetToWorldOriginLoading())
                            {
                                terrainScene.AddRegularReference(m_terrainLoaderManager.gameObject);
                            }
                        }
                    }

                    if (string.IsNullOrEmpty(terrainScene.m_impostorScenePath))
                    {
                        GUI.enabled = false;
                    }

                    if (isImpostorLoaded)
                    {
                        if (m_editorUtils.Button("UnLoadImpostor", GUILayout.Width(buttonWidth1)))
                        {
                            if (ResetToWorldOriginLoading())
                            {
                                terrainScene.RemoveImpostorReference(m_terrainLoaderManager.gameObject, 0, true);
                            }
                        }
                    }
                    else
                    {
                        if (m_editorUtils.Button("LoadImpostor", GUILayout.Width(buttonWidth1)))
                        {
                            if (ResetToWorldOriginLoading())
                            {
                                terrainScene.AddImpostorReference(m_terrainLoaderManager.gameObject);
                            }
                        }
                    }

                    GUI.enabled = originalGUIState;

                    if (m_editorUtils.Button("RemoveScene"))
                    {
                        if (EditorUtility.DisplayDialog(m_editorUtils.GetTextValue("RemoveSceneTitle"), m_editorUtils.GetTextValue("RemoveSceneText"), m_editorUtils.GetTextValue("Continue"), m_editorUtils.GetTextValue("Cancel")))
                        {
                            removeIndex = currentIndex;
                        }
                    }

                    EditorGUILayout.EndHorizontal();
                    if (terrainScene.RegularReferences.Count > 0)
                    {
                        EditorGUI.indentLevel++;
                        terrainScene.m_isFoldedOut = m_editorUtils.Foldout(terrainScene.m_isFoldedOut, "ShowTerrainReferences");
                        if (terrainScene.m_isFoldedOut)
                        {
                            foreach (GameObject go in terrainScene.RegularReferences)
                            {
                                EditorGUILayout.BeginHorizontal();
                                GUILayout.Space(20);
                                m_editorUtils.Label(new GUIContent(go.name, m_editorUtils.GetTextValue("TerrainReferenceToolTip")));
                                if (m_editorUtils.Button("TerrainReferenceSelect", GUILayout.Width(buttonWidth1)))
                                {
                                    Selection.activeObject = go;
                                    SceneView.lastActiveSceneView.FrameSelected();
                                }
                                if (m_editorUtils.Button("TerrainReferenceRemove", GUILayout.Width(buttonWidth2)))
                                {
                                    terrainScene.RemoveRegularReference(go);
                                }
                                GUILayout.Space(100);
                                EditorGUILayout.EndHorizontal();
                            }
                        }
                        EditorGUI.indentLevel--;
                    }
                    if (terrainScene.ImpostorReferences.Count > 0)
                    {
                        EditorGUI.indentLevel++;
                        terrainScene.m_isFoldedOut = m_editorUtils.Foldout(terrainScene.m_isFoldedOut, "ShowImpostorReferences");
                        if (terrainScene.m_isFoldedOut)
                        {
                            foreach (GameObject go in terrainScene.ImpostorReferences)
                            {
                                EditorGUILayout.BeginHorizontal();
                                GUILayout.Space(20);
                                m_editorUtils.Label(new GUIContent(go.name, m_editorUtils.GetTextValue("TerrainReferenceToolTip")));
                                if (m_editorUtils.Button("TerrainReferenceSelect", GUILayout.Width(buttonWidth1)))
                                {
                                    Selection.activeObject = go;
                                    SceneView.lastActiveSceneView.FrameSelected();
                                }
                                if (m_editorUtils.Button("TerrainReferenceRemove", GUILayout.Width(buttonWidth2)))
                                {
                                    terrainScene.RemoveImpostorReference(go);
                                }
                                GUILayout.Space(100);
                                EditorGUILayout.EndHorizontal();
                            }
                        }
                        EditorGUI.indentLevel--;
                    }
                }
                GUILayout.EndVertical();
                GUILayout.Space(5f);
                currentIndex++;
            }

            if (removeIndex != -99)
            {
                AssetDatabase.DeleteAsset(m_terrainLoaderManager.TerrainSceneStorage.m_terrainScenes[removeIndex].m_scenePath);
                m_terrainLoaderManager.TerrainSceneStorage.m_terrainScenes.RemoveAt(removeIndex);
                m_terrainLoaderManager.SaveStorageData();
            }
        }