示例#1
0
        private void SelectStampPanel(bool helpEnabled)
        {
            m_editorUtils.InlineHelp("Help", helpEnabled);


            if (m_editedImageMask == null && m_editedStamperSettings == null)
            {
                EditorGUILayout.HelpBox(m_editorUtils.GetTextValue("NoConnectedImageMask"), MessageType.Warning, true);
            }

            m_editorUtils.Label("StampPreview");
            EditorGUILayout.BeginVertical();
            if (m_previewTexture != null && m_validStampInCategory)
            {
                m_editorUtils.Image(m_previewTexture, position.width - 25, position.width - 25);
                m_editorUtils.Label(new GUIContent(m_previewTexture.name));
            }
            else
            {
                if (!m_validStampInCategory)
                {
                    GUILayout.Space(71);
                    EditorGUILayout.HelpBox(m_editorUtils.GetTextValue("NoValidStampInCategory"), MessageType.Info, true);
                }
                else if (m_previewTexture == null)
                {
                    GUILayout.Space(67);
                    EditorGUILayout.HelpBox(m_editorUtils.GetTextValue("NoTexture"), MessageType.Info, true);
                }
                GUILayout.Space(155);
            }
            GUILayout.Space(EditorGUIUtility.singleLineHeight);

            Rect rect = EditorGUILayout.GetControlRect();

            if (GUI.Button(new Rect(rect.x, rect.y, 50, EditorGUIUtility.singleLineHeight), m_editorUtils.GetContent("StampBackwardButton")))
            {
                PickNextStamp(-1);
            }

            //Building up a value array of incrementing ints of the size of the directory names array, this array will then match the displayed string selection in the popup
            int[] categoryIDArray = Enumerable
                                    .Repeat(0, (int)((m_categoryNames.ToArray().Length - 0) / 1) + 1)
                                    .Select((tr, ti) => tr + (1 * ti))
                                    .ToArray();

            int previousCategoryID = m_selectedCategoryID;

            m_selectedCategoryID = EditorGUI.IntPopup(new Rect(rect.x + 60, rect.y, rect.width - 120, EditorGUIUtility.singleLineHeight), m_selectedCategoryID, m_categoryNames.ToArray(), categoryIDArray);
            if (previousCategoryID != m_selectedCategoryID)
            {
                LoadStampDirFileInfo();
                m_currentStampIndex    = -1;
                m_validStampInCategory = PickNextStamp(1);
            }

            if (GUI.Button(new Rect(rect.x + 60 + rect.width - 110, rect.y, 50, EditorGUIUtility.singleLineHeight), m_editorUtils.GetContent("StampForwardButton")))
            {
                PickNextStamp(1);
            }

            rect.y += EditorGUIUtility.singleLineHeight * 2;

            if (GUI.Button(new Rect(rect.x + 20, rect.y, 100, EditorGUIUtility.singleLineHeight * 2), m_editorUtils.GetContent("ApplyButton")))
            {
                Close();
            }
            if (GUI.Button(new Rect(rect.x + rect.width - 100 - 20, rect.y, 100, EditorGUIUtility.singleLineHeight * 2), m_editorUtils.GetContent("CancelButton")))
            {
                //Load original stamp back in and close
                if (m_editedImageMask != null)
                {
                    m_editedImageMask.ImageMaskTexture = (Texture2D)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(m_originalTextureGUID), typeof(Texture2D));
                }
                //if (m_editedStamperSettings != null)
                //{
                //    m_editedStamperSettings.m_stamperInputImage = (Texture2D)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(m_originalTextureGUID), typeof(Texture2D));
                //}
                UpdateToolsAndScene();
                Close();
            }


            EditorGUILayout.EndVertical();
        }
示例#2
0
        private void DrawGeneralSettings(bool helpEnabled)
        {
            m_terrainLoaderManager.TerrainSceneStorage = (TerrainSceneStorage)m_editorUtils.ObjectField("TerrainSceneStorage", m_terrainLoaderManager.TerrainSceneStorage, typeof(TerrainSceneStorage), false, helpEnabled);

            bool oldLoadingEnabled = m_terrainLoaderManager.TerrainSceneStorage.m_terrainLoadingEnabled;

            m_terrainLoaderManager.TerrainSceneStorage.m_terrainLoadingEnabled = m_editorUtils.Toggle("TerrainLoadingEnabled", m_terrainLoaderManager.TerrainSceneStorage.m_terrainLoadingEnabled, helpEnabled);
            if (!oldLoadingEnabled && m_terrainLoaderManager.TerrainSceneStorage.m_terrainLoadingEnabled)
            {
                //User re-enabled the loaders
                m_terrainLoaderManager.UpdateTerrainLoadState();
            }
            if (oldLoadingEnabled != m_terrainLoaderManager.TerrainSceneStorage.m_terrainLoadingEnabled)
            {
                //Value was changed, dirty the object to make sure the value is being saved
                EditorUtility.SetDirty(m_terrainLoaderManager.TerrainSceneStorage);
            }

            bool originalGUIState = GUI.enabled;

            m_terrainLoaderManager.m_terrainLoadingTresholdMS    = m_editorUtils.IntField("LoadingTimeTreshold", m_terrainLoaderManager.m_terrainLoadingTresholdMS, helpEnabled);
            m_terrainLoaderManager.m_trackLoadingProgressTimeOut = m_editorUtils.LongField("LoadingProgressTimeout", m_terrainLoaderManager.m_trackLoadingProgressTimeOut, helpEnabled);
            GUILayout.Space(10);
            m_editorUtils.Heading("SceneViewLoading");
            m_terrainLoaderManager.CenterSceneViewLoadingOn = (CenterSceneViewLoadingOn)m_editorUtils.EnumPopup("CenterSceneViewLoadingOn", m_terrainLoaderManager.CenterSceneViewLoadingOn, helpEnabled);
            double loadingRange         = m_editorUtils.DoubleField("SceneViewLoadingRange", m_terrainLoaderManager.GetLoadingRange(), helpEnabled);
            double impostorLoadingRange = m_terrainLoaderManager.GetImpostorLoadingRange();

            if (GaiaUtils.HasImpostorTerrains())
            {
                impostorLoadingRange = m_editorUtils.DoubleField("SceneViewImpostorLoadingRange", m_terrainLoaderManager.GetImpostorLoadingRange(), helpEnabled);
            }
            else
            {
                EditorGUILayout.BeginHorizontal();
                m_editorUtils.Label("SceneViewImpostorLoadingRange");
                //offer button to create impostors setup
                if (m_editorUtils.Button("OpenTerrainMeshExporterForImpostors", GUILayout.Width(EditorGUIUtility.currentViewWidth - EditorGUIUtility.labelWidth - 38)))
                {
                    ExportTerrain exportTerrainWindow = EditorWindow.GetWindow <ExportTerrain>();
                    exportTerrainWindow.FindAndSetPreset("Create Impostors");
                    exportTerrainWindow.m_settings.m_customSettingsFoldedOut = false;
                }
                EditorGUILayout.EndHorizontal();
            }

            if (loadingRange != m_terrainLoaderManager.GetLoadingRange() || impostorLoadingRange != m_terrainLoaderManager.GetImpostorLoadingRange())
            {
                m_terrainLoaderManager.SetLoadingRange(loadingRange, impostorLoadingRange);
            }

            GUILayout.Space(10);
            m_editorUtils.Heading("CachingSettings");
            m_editorUtils.InlineHelp("CachingSettings", helpEnabled);
            EditorGUI.BeginChangeCheck();
            m_terrainLoaderManager.m_cacheInRuntime = m_editorUtils.Toggle("CacheInRuntime", m_terrainLoaderManager.m_cacheInRuntime, helpEnabled);
            m_terrainLoaderManager.m_cacheInEditor  = m_editorUtils.Toggle("CacheInEditor", m_terrainLoaderManager.m_cacheInEditor, helpEnabled);
            string allocatedMegabytes = (Math.Round(Profiler.GetTotalAllocatedMemoryLong() / Math.Pow(1024, 2))).ToString();
            string availableMegabytes = SystemInfo.systemMemorySize.ToString();

            allocatedMegabytes = allocatedMegabytes.PadLeft(allocatedMegabytes.Length + (availableMegabytes.Length - allocatedMegabytes.Length) * 3, ' ');

            GUIStyle style = new GUIStyle(GUI.skin.label);

            if (m_terrainLoaderManager.m_cacheMemoryThreshold < Profiler.GetTotalAllocatedMemoryLong())
            {
                style = redStyle;
            }
            else
            {
                style = greenStyle;
            }
            m_editorUtils.LabelField("MemoryAvailable", new GUIContent(availableMegabytes), helpEnabled);
            m_editorUtils.LabelField("MemoryAllocated", new GUIContent(allocatedMegabytes), style, helpEnabled);

            //GUI.color = originalGUIColor;

            if (m_terrainLoaderManager.m_cacheInRuntime || m_terrainLoaderManager.m_cacheInEditor)
            {
                m_terrainLoaderManager.m_cacheMemoryThresholdPreset = (CacheSizePreset)m_editorUtils.EnumPopup("CacheMemoryThreshold", m_terrainLoaderManager.m_cacheMemoryThresholdPreset, helpEnabled);
                if (m_terrainLoaderManager.m_cacheMemoryThresholdPreset == CacheSizePreset.Custom)
                {
                    EditorGUI.indentLevel++;
                    m_terrainLoaderManager.m_cacheMemoryThreshold = m_editorUtils.LongField("ThresholdInBytes", m_terrainLoaderManager.m_cacheMemoryThreshold, helpEnabled);
                    EditorGUI.indentLevel--;
                }
                int cacheKeepAliveSeconds = (int)m_terrainLoaderManager.m_cacheKeepAliveTime / 1000;
                cacheKeepAliveSeconds = m_editorUtils.IntField("CacheKeepAliveSeconds", cacheKeepAliveSeconds, helpEnabled);
                m_terrainLoaderManager.m_cacheKeepAliveTime = cacheKeepAliveSeconds * 1000;
            }
            if (EditorGUI.EndChangeCheck())
            {
                if (m_terrainLoaderManager.m_cacheMemoryThresholdPreset != CacheSizePreset.Custom)
                {
                    m_terrainLoaderManager.m_cacheMemoryThreshold = (long)((int)m_terrainLoaderManager.m_cacheMemoryThresholdPreset * Math.Pow(1024, 3));
                }
                m_terrainLoaderManager.UpdateCaching();
            }



            GUILayout.Space(10);

            if (!GaiaUtils.HasColliderTerrains())
            {
                GUI.enabled = false;
            }

            m_editorUtils.Heading("ColliderOnlyLoadingHeader");
            //This flag is special in so far as that when the user switches it, we must first perform a scene unload while the old value is still active
            //then change the flag in the terrain scene storage and then do a refresh with the new setting applied.
            bool colliderLoadingEnabled = m_terrainLoaderManager.TerrainSceneStorage.m_colliderOnlyLoading;

            colliderLoadingEnabled = m_editorUtils.Toggle("ColliderOnlyLoadingEnabled", colliderLoadingEnabled, helpEnabled);
            if (colliderLoadingEnabled != m_terrainLoaderManager.TerrainSceneStorage.m_colliderOnlyLoading)
            {
                //User changed the flag, do an unload with the old setting
                m_terrainLoaderManager.UnloadAll(true);
                //then change the actual flag in storage
                m_terrainLoaderManager.TerrainSceneStorage.m_colliderOnlyLoading = colliderLoadingEnabled;
                //now do a refresh under the new setting
                m_terrainLoaderManager.RefreshSceneViewLoadingRange();

                //Add the required scenes to build settings
                if (colliderLoadingEnabled)
                {
                    GaiaSessionManager.AddOnlyColliderScenesToBuildSettings(TerrainLoaderManager.TerrainScenes);
                }
                else
                {
                    GaiaSessionManager.AddTerrainScenesToBuildSettings(TerrainLoaderManager.TerrainScenes);
                }
            }

            GUI.enabled = originalGUIState;

            if (colliderLoadingEnabled)
            {
                EditorGUILayout.HelpBox(m_editorUtils.GetTextValue("ColliderOnlyLoadingInfo"), MessageType.Info);
                m_editorUtils.Heading("DeactivateRuntimeHeader");
                EditorGUI.indentLevel++;
                m_terrainLoaderManager.TerrainSceneStorage.m_deactivateRuntimePlayer        = m_editorUtils.Toggle("DeactivateRuntimePlayer", m_terrainLoaderManager.TerrainSceneStorage.m_deactivateRuntimePlayer, helpEnabled);
                m_terrainLoaderManager.TerrainSceneStorage.m_deactivateRuntimeLighting      = m_editorUtils.Toggle("DeactivateRuntimeLighting", m_terrainLoaderManager.TerrainSceneStorage.m_deactivateRuntimeLighting, helpEnabled);
                m_terrainLoaderManager.TerrainSceneStorage.m_deactivateRuntimeAudio         = m_editorUtils.Toggle("DeactivateRuntimeAudio", m_terrainLoaderManager.TerrainSceneStorage.m_deactivateRuntimeAudio, helpEnabled);
                m_terrainLoaderManager.TerrainSceneStorage.m_deactivateRuntimeWeather       = m_editorUtils.Toggle("DeactivateRuntimeWeather", m_terrainLoaderManager.TerrainSceneStorage.m_deactivateRuntimeWeather, helpEnabled);
                m_terrainLoaderManager.TerrainSceneStorage.m_deactivateRuntimeWater         = m_editorUtils.Toggle("DeactivateRuntimeWater", m_terrainLoaderManager.TerrainSceneStorage.m_deactivateRuntimeWater, helpEnabled);
                m_terrainLoaderManager.TerrainSceneStorage.m_deactivateRuntimeScreenShotter = m_editorUtils.Toggle("DeactivateRuntimeScreenShotter", m_terrainLoaderManager.TerrainSceneStorage.m_deactivateRuntimeScreenShotter, helpEnabled);
                EditorGUI.indentLevel--;
            }
            else
            {
                //offer button to create collider setup
                if (m_editorUtils.Button("OpenTerrainMeshExporterForColliders"))
                {
                    ExportTerrain exportTerrainWindow = EditorWindow.GetWindow <ExportTerrain>();
                    exportTerrainWindow.FindAndSetPreset("Collider");
                    exportTerrainWindow.m_settings.m_customSettingsFoldedOut = false;
                }
            }
        }