Example #1
0
 internal static void NotifyLanguageChanged(SystemLanguage newLanguage)
 {
     s_TextGUIContents = new Hashtable();
     EditorUtility.Internal_UpdateMenuTitleForLanguage(newLanguage);
     LocalizationDatabase.SetCurrentEditorLanguage(newLanguage);
     EditorApplication.RequestRepaintAllViews();
 }
 public override void OnClose()
 {
     m_Object           = null;
     m_AcceptedCallback = null;
     m_IsInitialized    = false;
     EditorApplication.RequestRepaintAllViews(); // When closed ensure FlexibileMenu gets repainted so hover can be removed
 }
Example #3
0
 public override void OnClose()
 {
     this.m_Object           = null;
     this.m_AcceptedCallback = null;
     this.m_IsInitialized    = false;
     EditorApplication.RequestRepaintAllViews();
 }
        private void CloseSelectedScenes(bool removeScenes)
        {
            List <int> selectedScenes = this.GetSelectedScenes();

            if (EditorSceneManager.SaveModifiedScenesIfUserWantsTo(this.GetModifiedScenes(selectedScenes)))
            {
                foreach (int num in selectedScenes)
                {
                    EditorSceneManager.CloseScene(EditorSceneManager.GetSceneByHandle(num), removeScenes);
                }
                EditorApplication.RequestRepaintAllViews();
            }
        }
        private void LoadSelectedScenes(object userdata)
        {
            List <int> selectedScenes = this.GetSelectedScenes();

            foreach (int current in selectedScenes)
            {
                Scene sceneByHandle = EditorSceneManager.GetSceneByHandle(current);
                if (!sceneByHandle.isLoaded)
                {
                    EditorSceneManager.OpenScene(sceneByHandle.path, OpenSceneMode.Additive);
                }
            }
            EditorApplication.RequestRepaintAllViews();
        }
 private void LoadSelectedScenes(object userdata)
 {
     using (List <int> .Enumerator enumerator = this.GetSelectedScenes().GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             Scene sceneByHandle = EditorSceneManager.GetSceneByHandle(enumerator.Current);
             if (!sceneByHandle.isLoaded)
             {
                 EditorSceneManager.OpenScene(sceneByHandle.path, OpenSceneMode.Additive);
             }
         }
     }
     EditorApplication.RequestRepaintAllViews();
 }
Example #7
0
 private void EditExistingItem(Rect itemRect, int index)
 {
     if (this.m_ModifyItemUI != null)
     {
         itemRect.y -= itemRect.height;
         itemRect.x += itemRect.width;
         this.m_ModifyItemUI.Init(FlexibleMenuModifyItemUI.MenuType.Edit, this.m_ItemProvider.GetItem(index), delegate(object obj)
         {
             this.ClearCachedWidth();
             this.m_ItemProvider.Replace(index, obj);
             EditorApplication.RequestRepaintAllViews();
         });
         PopupWindow.Show(itemRect, this.m_ModifyItemUI, null, ShowMode.PopupMenuWithKeyboardFocus);
     }
 }
        private void CloseSelectedScenes(bool removeScenes)
        {
            List <int> selectedScenes = this.GetSelectedScenes();

            Scene[] modifiedScenes = this.GetModifiedScenes(selectedScenes);
            bool    flag           = !EditorSceneManager.SaveModifiedScenesIfUserWantsTo(modifiedScenes);

            if (flag)
            {
                return;
            }
            foreach (int current in selectedScenes)
            {
                EditorSceneManager.CloseScene(EditorSceneManager.GetSceneByHandle(current), removeScenes);
            }
            EditorApplication.RequestRepaintAllViews();
        }
        private void CloseSelectedScenes(bool removeScenes)
        {
            List <int> selectedScenes = this.GetSelectedScenes();

            if (!EditorSceneManager.SaveModifiedScenesIfUserWantsTo(this.GetModifiedScenes(selectedScenes)))
            {
                return;
            }
            using (List <int> .Enumerator enumerator = selectedScenes.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    EditorSceneManager.CloseScene(EditorSceneManager.GetSceneByHandle(enumerator.Current), removeScenes);
                }
            }
            EditorApplication.RequestRepaintAllViews();
        }
        private void ShowColors()
        {
            if (this.s_CachedColors == null)
            {
                this.s_CachedColors = this.OrderPrefs <PrefColor>(Settings.Prefs <PrefColor>());
            }
            bool flag = false;

            PreferencesWindow.s_ColorScrollPos = EditorGUILayout.BeginScrollView(PreferencesWindow.s_ColorScrollPos, new GUILayoutOption[0]);
            GUILayout.Space(10f);
            PrefColor prefColor = null;

            foreach (KeyValuePair <string, List <KeyValuePair <string, PrefColor> > > current in this.s_CachedColors)
            {
                GUILayout.Label(current.Key, EditorStyles.boldLabel, new GUILayoutOption[0]);
                foreach (KeyValuePair <string, PrefColor> current2 in current.Value)
                {
                    EditorGUI.BeginChangeCheck();
                    Color color = EditorGUILayout.ColorField(current2.Key, current2.Value.Color, new GUILayoutOption[0]);
                    if (EditorGUI.EndChangeCheck())
                    {
                        prefColor       = current2.Value;
                        prefColor.Color = color;
                        flag            = true;
                    }
                }
                if (prefColor != null)
                {
                    Settings.Set <PrefColor>(prefColor.Name, prefColor);
                }
            }
            GUILayout.EndScrollView();
            GUILayout.Space(5f);
            if (GUILayout.Button("Use Defaults", new GUILayoutOption[]
            {
                GUILayout.Width(120f)
            }))
            {
                this.RevertColors();
                flag = true;
            }
            if (flag)
            {
                EditorApplication.RequestRepaintAllViews();
            }
        }
Example #11
0
 private void CreateNewItemButton(Rect itemRect)
 {
     if (this.m_ModifyItemUI != null)
     {
         Rect position = new Rect(itemRect.x + 25f, itemRect.y, 15f, 15f);
         if (GUI.Button(position, s_Styles.plusButtonText, "OL Plus"))
         {
             position.y -= 15f;
             this.m_ModifyItemUI.Init(FlexibleMenuModifyItemUI.MenuType.Add, this.m_ItemProvider.Create(), delegate(object obj) {
                 this.ClearCachedWidth();
                 int index = this.m_ItemProvider.Add(obj);
                 this.SelectItem(index);
                 EditorApplication.RequestRepaintAllViews();
             });
             PopupWindow.Show(position, this.m_ModifyItemUI);
         }
     }
 }
        void EditExistingItem(Rect itemRect, int index)
        {
            if (m_ModifyItemUI == null)
            {
                return;
            }

            itemRect.y -= itemRect.height;
            itemRect.x += itemRect.width;
            m_ModifyItemUI.Init(FlexibleMenuModifyItemUI.MenuType.Edit, m_ItemProvider.GetItem(index),
                                delegate(object obj)
            {
                ClearCachedWidth();
                m_ItemProvider.Replace(index, obj);
                EditorApplication.RequestRepaintAllViews();     // We want to repaint the flexible menu (currently in modifyItemUI)
            });
            PopupWindow.Show(itemRect, m_ModifyItemUI, null, ShowMode.PopupMenuWithKeyboardFocus);
        }
Example #13
0
        private void ShowColors(string searchContext)
        {
            if (s_CachedColors == null)
            {
                s_CachedColors = OrderPrefs(PrefSettings.Prefs <PrefColor>());
            }

            var       changedColor = false;
            PrefColor ccolor       = null;

            foreach (KeyValuePair <string, List <KeyValuePair <string, PrefColor> > > category in s_CachedColors)
            {
                GUILayout.Label(category.Key, EditorStyles.boldLabel);
                foreach (KeyValuePair <string, PrefColor> kvp in category.Value)
                {
                    EditorGUI.BeginChangeCheck();
                    Color c = EditorGUILayout.ColorField(kvp.Key, kvp.Value.Color);
                    if (EditorGUI.EndChangeCheck())
                    {
                        ccolor       = kvp.Value;
                        ccolor.Color = c;
                        changedColor = true;
                    }
                }
                if (ccolor != null)
                {
                    PrefSettings.Set(ccolor.Name, ccolor);
                }
            }
            GUILayout.Space(5f);

            if (GUILayout.Button(ColorsProperties.userDefaults, GUILayout.Width(120)))
            {
                RevertColors();
                changedColor = true;
            }

            if (changedColor)
            {
                EditorApplication.RequestRepaintAllViews();
            }
        }
Example #14
0
        private void CreateNewItemButton(Rect itemRect)
        {
            if (this.m_ModifyItemUI == null)
            {
                return;
            }
            Rect rect = new Rect(itemRect.x + 25f, itemRect.y, 15f, 15f);

            if (!GUI.Button(rect, FlexibleMenu.s_Styles.plusButtonText, (GUIStyle)"OL Plus"))
            {
                return;
            }
            rect.y -= 15f;
            this.m_ModifyItemUI.Init(FlexibleMenuModifyItemUI.MenuType.Add, this.m_ItemProvider.Create(), (System.Action <object>)(obj =>
            {
                this.ClearCachedWidth();
                this.SelectItem(this.m_ItemProvider.Add(obj));
                EditorApplication.RequestRepaintAllViews();
            }));
            PopupWindow.Show(rect, (PopupWindowContent)this.m_ModifyItemUI);
        }
        void CreateNewItemButton(Rect itemRect)
        {
            if (m_ModifyItemUI == null)
            {
                return;
            }

            Rect plusRect = new Rect(itemRect.x + leftMargin, itemRect.y, 15, 15);

            if (GUI.Button(plusRect, s_Styles.plusButtonText, "OL Plus"))
            {
                plusRect.y -= 15f;
                m_ModifyItemUI.Init(FlexibleMenuModifyItemUI.MenuType.Add, m_ItemProvider.Create(),
                                    delegate(object obj)
                {
                    ClearCachedWidth();
                    int newIndex = m_ItemProvider.Add(obj);
                    SelectItem(newIndex);
                    EditorApplication.RequestRepaintAllViews();     // We want to repaint the flexible menu (currently in modifyItemUI)
                });
                PopupWindow.Show(plusRect, m_ModifyItemUI, null, ShowMode.PopupMenuWithKeyboardFocus);
            }
        }
Example #16
0
 public static void Update()
 {
     // TODO: how can this not be exposed as an public API?
     EditorApplication.RequestRepaintAllViews();
 }
        public override void OnInspectorGUI()
        {
            bool enabled = GUI.enabled;

            this.ShowUnityRemoteGUI(enabled);
            GUILayout.Space(10f);
            bool flag = Collab.instance.GetCollabInfo().whitelisted&& CollabAccess.Instance.IsServiceEnabled();

            using (new EditorGUI.DisabledScope(!flag))
            {
                GUI.enabled = !flag;
                GUILayout.Label("Version Control", EditorStyles.boldLabel, new GUILayoutOption[0]);
                GUI.enabled = (enabled && !flag);
                ExternalVersionControl d = EditorSettings.externalVersionControl;
                this.CreatePopupMenu("Mode", this.vcPopupList, d, new GenericMenu.MenuFunction2(this.SetVersionControlSystem));
            }
            if (flag)
            {
                EditorGUILayout.HelpBox("Version Control not available when using Collaboration feature.", MessageType.Warning);
            }
            if (this.VersionControlSystemHasGUI())
            {
                GUI.enabled = true;
                bool flag2 = false;
                if (EditorSettings.externalVersionControl == ExternalVersionControl.AssetServer)
                {
                    EditorUserSettings.SetConfigValue("vcUsername", EditorGUILayout.TextField("User", EditorUserSettings.GetConfigValue("vcUsername"), new GUILayoutOption[0]));
                    EditorUserSettings.SetConfigValue("vcPassword", EditorGUILayout.PasswordField("Password", EditorUserSettings.GetConfigValue("vcPassword"), new GUILayoutOption[0]));
                }
                else if (!(EditorSettings.externalVersionControl == ExternalVersionControl.Generic))
                {
                    if (!(EditorSettings.externalVersionControl == ExternalVersionControl.Disabled))
                    {
                        ConfigField[] activeConfigFields = Provider.GetActiveConfigFields();
                        flag2 = true;
                        ConfigField[] array = activeConfigFields;
                        for (int i = 0; i < array.Length; i++)
                        {
                            ConfigField configField = array[i];
                            string      configValue = EditorUserSettings.GetConfigValue(configField.name);
                            string      text;
                            if (configField.isPassword)
                            {
                                text = EditorGUILayout.PasswordField(configField.label, configValue, new GUILayoutOption[0]);
                            }
                            else
                            {
                                text = EditorGUILayout.TextField(configField.label, configValue, new GUILayoutOption[0]);
                            }
                            if (text != configValue)
                            {
                                EditorUserSettings.SetConfigValue(configField.name, text);
                            }
                            if (configField.isRequired && string.IsNullOrEmpty(text))
                            {
                                flag2 = false;
                            }
                        }
                    }
                }
                string logLevel = EditorUserSettings.GetConfigValue("vcSharedLogLevel");
                int    num      = Array.FindIndex <string>(this.logLevelPopupList, (string item) => item.ToLower() == logLevel);
                if (num == -1)
                {
                    logLevel = "info";
                }
                int num2 = EditorGUILayout.Popup("Log Level", Math.Abs(num), this.logLevelPopupList, new GUILayoutOption[0]);
                if (num2 != num)
                {
                    EditorUserSettings.SetConfigValue("vcSharedLogLevel", this.logLevelPopupList[num2].ToLower());
                }
                GUI.enabled = enabled;
                string label = "Connected";
                if (Provider.onlineState == OnlineState.Updating)
                {
                    label = "Connecting...";
                }
                else if (Provider.onlineState == OnlineState.Offline)
                {
                    label = "Disconnected";
                }
                EditorGUILayout.LabelField("Status", label, new GUILayoutOption[0]);
                if (Provider.onlineState != OnlineState.Online && !string.IsNullOrEmpty(Provider.offlineReason))
                {
                    GUI.enabled = false;
                    GUILayout.TextArea(Provider.offlineReason, new GUILayoutOption[0]);
                    GUI.enabled = enabled;
                }
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.FlexibleSpace();
                GUI.enabled = (flag2 && Provider.onlineState != OnlineState.Updating);
                if (GUILayout.Button("Connect", EditorStyles.miniButton, new GUILayoutOption[0]))
                {
                    Provider.UpdateSettings();
                }
                GUILayout.EndHorizontal();
                EditorUserSettings.AutomaticAdd = EditorGUILayout.Toggle("Automatic add", EditorUserSettings.AutomaticAdd, new GUILayoutOption[0]);
                if (Provider.requiresNetwork)
                {
                    bool flag3 = EditorGUILayout.Toggle("Work Offline", EditorUserSettings.WorkOffline, new GUILayoutOption[0]);
                    if (flag3 != EditorUserSettings.WorkOffline)
                    {
                        if (flag3 && !EditorUtility.DisplayDialog("Confirm working offline", "Working offline and making changes to your assets means that you will have to manually integrate changes back into version control using your standard version control client before you stop working offline in Unity. Make sure you know what you are doing.", "Work offline", "Cancel"))
                        {
                            flag3 = false;
                        }
                        EditorUserSettings.WorkOffline = flag3;
                        EditorApplication.RequestRepaintAllViews();
                    }
                }
                if (Provider.hasCheckoutSupport)
                {
                    EditorUserSettings.showFailedCheckout = EditorGUILayout.Toggle("Show failed checkouts", EditorUserSettings.showFailedCheckout, new GUILayoutOption[0]);
                }
                GUI.enabled = enabled;
                EditorUserSettings.semanticMergeMode = (SemanticMergeMode)EditorGUILayout.Popup("Smart merge", (int)EditorUserSettings.semanticMergeMode, this.semanticMergePopupList, new GUILayoutOption[0]);
                this.DrawOverlayDescriptions();
            }
            GUILayout.Space(10f);
            GUILayout.Label("WWW Security Emulation", EditorStyles.boldLabel, new GUILayoutOption[0]);
            EditorSettings.webSecurityEmulationEnabled = EditorGUILayout.Toggle("Enable Webplayer Security Emulation", EditorSettings.webSecurityEmulationEnabled, new GUILayoutOption[0]);
            string text2 = EditorGUILayout.TextField("Host URL", EditorSettings.webSecurityEmulationHostUrl, new GUILayoutOption[0]);

            if (text2 != EditorSettings.webSecurityEmulationHostUrl)
            {
                EditorSettings.webSecurityEmulationHostUrl = text2;
            }
            GUILayout.Space(10f);
            int selectedIndex = (int)EditorSettings.serializationMode;

            using (new EditorGUI.DisabledScope(!flag))
            {
                GUI.enabled = !flag;
                GUILayout.Label("Asset Serialization", EditorStyles.boldLabel, new GUILayoutOption[0]);
                GUI.enabled = (enabled && !flag);
                this.CreatePopupMenu("Mode", this.serializationPopupList, selectedIndex, new GenericMenu.MenuFunction2(this.SetAssetSerializationMode));
            }
            if (flag)
            {
                EditorGUILayout.HelpBox("Asset Serialization is forced to Text when using Collaboration feature.", MessageType.Warning);
            }
            GUILayout.Space(10f);
            GUI.enabled = true;
            GUILayout.Label("Default Behavior Mode", EditorStyles.boldLabel, new GUILayoutOption[0]);
            GUI.enabled   = enabled;
            selectedIndex = Mathf.Clamp((int)EditorSettings.defaultBehaviorMode, 0, this.behaviorPopupList.Length - 1);
            this.CreatePopupMenu("Mode", this.behaviorPopupList, selectedIndex, new GenericMenu.MenuFunction2(this.SetDefaultBehaviorMode));
            GUILayout.Space(10f);
            GUI.enabled = true;
            GUILayout.Label("Sprite Packer", EditorStyles.boldLabel, new GUILayoutOption[0]);
            GUI.enabled   = enabled;
            selectedIndex = Mathf.Clamp((int)EditorSettings.spritePackerMode, 0, this.spritePackerPopupList.Length - 1);
            this.CreatePopupMenu("Mode", this.spritePackerPopupList, selectedIndex, new GenericMenu.MenuFunction2(this.SetSpritePackerMode));
            selectedIndex = Mathf.Clamp(EditorSettings.spritePackerPaddingPower - 1, 0, 2);
            this.CreatePopupMenu("Padding Power", this.spritePackerPaddingPowerPopupList, selectedIndex, new GenericMenu.MenuFunction2(this.SetSpritePackerPaddingPower));
            this.DoProjectGenerationSettings();
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            GUILayout.Space(10);
            GUILayout.BeginVertical(EditorStyles.inspectorDefaultMargins);

            bool collabEnabled = Collab.instance.IsCollabEnabledForCurrentProject();

            using (new EditorGUI.DisabledScope(!collabEnabled))
            {
                GUI.enabled = !collabEnabled;

                ExternalVersionControl selvc = VersionControlSettings.mode;
                CreatePopupMenuVersionControl(Styles.mode.text, vcPopupList, selvc, SetVersionControlSystem);
                GUI.enabled = !collabEnabled;
            }

            if (collabEnabled)
            {
                EditorGUILayout.HelpBox("Version Control not available when using Collaboration feature.",
                                        MessageType.Warning);
            }

            GUI.enabled = true;
            ConfigField[] configFields = null;

            var versionControlSystemHasGUI = VersionControlSystemHasGUI();
            var vco = versionControlSystemHasGUI ? VersionControlManager.activeVersionControlObject : null;

            if (vco != null)
            {
                vco.GetExtension <ISettingsInspectorExtension>()?.OnInspectorGUI();
            }
            else if (versionControlSystemHasGUI)
            {
                bool hasRequiredFields = false;

                if (VersionControlSettings.mode == ExternalVersionControl.Generic ||
                    VersionControlSettings.mode == ExternalVersionControl.Disabled)
                {
                    // no specific UI for these VCS types
                }
                else
                {
                    configFields = Provider.GetActiveConfigFields();

                    hasRequiredFields = true;

                    foreach (ConfigField field in configFields)
                    {
                        string newVal;
                        string oldVal = EditorUserSettings.GetConfigValue(field.name);
                        if (field.isPassword)
                        {
                            newVal = EditorGUILayout.PasswordField(GUIContent.Temp(field.label, field.description),
                                                                   oldVal);
                            if (newVal != oldVal)
                            {
                                EditorUserSettings.SetPrivateConfigValue(field.name, newVal);
                            }
                        }
                        else
                        {
                            var recentValues = GetVCConfigFieldRecentValues(field.name);
                            newVal = EditorGUILayout.TextFieldDropDown(GUIContent.Temp(field.label, field.description),
                                                                       oldVal, recentValues);
                            if (newVal != oldVal)
                            {
                                EditorUserSettings.SetConfigValue(field.name, newVal);
                            }
                        }

                        if (field.isRequired && string.IsNullOrEmpty(newVal))
                        {
                            hasRequiredFields = false;
                        }
                    }
                }

                // Log level popup
                string logLevel = EditorUserSettings.GetConfigValue("vcSharedLogLevel");
                int    idx      = System.Array.FindIndex(logLevelPopupList, (item) => item.ToLower() == logLevel);
                if (idx == -1)
                {
                    logLevel = "notice";
                    idx      = System.Array.FindIndex(logLevelPopupList, (item) => item.ToLower() == logLevel);
                    if (idx == -1)
                    {
                        idx = 0;
                    }

                    logLevel = logLevelPopupList[idx];
                    EditorUserSettings.SetConfigValue("vcSharedLogLevel", logLevel);
                }

                int newIdx = EditorGUILayout.Popup(Styles.logLevel, idx, logLevelPopupList);
                if (newIdx != idx)
                {
                    EditorUserSettings.SetConfigValue("vcSharedLogLevel", logLevelPopupList[newIdx].ToLower());
                }

                if (Provider.onlineState == OnlineState.Offline)
                {
                    var text = "Not Connected. " + (Provider.offlineReason ?? "");
                    EditorGUILayout.HelpBox(text, MessageType.Error);
                }
                else if (Provider.onlineState == OnlineState.Updating)
                {
                    var text = "Connecting...";
                    EditorGUILayout.HelpBox(text, MessageType.Info);
                }
                else if (EditorUserSettings.WorkOffline)
                {
                    var text =
                        "Working Offline. Manually integrate your changes using a version control client, and uncheck 'Work Offline' setting below to get back to regular state.";
                    EditorGUILayout.HelpBox(text, MessageType.Warning);
                }
                else if (Provider.onlineState == OnlineState.Online)
                {
                    var text = "Connected";
                    EditorGUILayout.HelpBox(text, MessageType.Info);
                }

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUI.enabled = hasRequiredFields && Provider.onlineState != OnlineState.Updating;
                if (GUILayout.Button(
                        Provider.onlineState != OnlineState.Offline ? Styles.vcsReconnect : Styles.vcsConnect,
                        EditorStyles.miniButton))
                {
                    m_NeedToSaveValuesOnConnect = true;
                    Provider.UpdateSettings();
                }

                GUILayout.EndHorizontal();

                if (m_NeedToSaveValuesOnConnect && Provider.onlineState == OnlineState.Online)
                {
                    // save connection field settings if we got online with them successfully
                    m_NeedToSaveValuesOnConnect = false;
                    UpdateVCConfigFieldRecentValues(configFields);
                }

                if (Provider.requiresNetwork)
                {
                    bool workOfflineNew =
                        EditorGUILayout.Toggle(Styles.workOffline,
                                               EditorUserSettings.WorkOffline); // Enabled has a slightly different behaviour
                    if (workOfflineNew != EditorUserSettings.WorkOffline)
                    {
                        // On toggling on show a warning
                        if (workOfflineNew && !EditorUtility.DisplayDialog("Confirm working offline",
                                                                           "Working offline and making changes to your assets means that you will have to manually integrate changes back into version control using your standard version control client before you stop working offline in Unity. Make sure you know what you are doing.",
                                                                           "Work offline", "Cancel"))
                        {
                            workOfflineNew = false; // User cancelled working offline
                        }

                        EditorUserSettings.WorkOffline = workOfflineNew;
                        EditorApplication.RequestRepaintAllViews();
                    }
                }

                EditorUserSettings.AutomaticAdd =
                    EditorGUILayout.Toggle(Styles.automaticAdd, EditorUserSettings.AutomaticAdd);

                if (Provider.requiresNetwork)
                {
                    EditorUserSettings.allowAsyncStatusUpdate = EditorGUILayout.Toggle(Styles.allowAsyncUpdate,
                                                                                       EditorUserSettings.allowAsyncStatusUpdate);
                }

                if (Provider.hasCheckoutSupport)
                {
                    EditorUserSettings.showFailedCheckout = EditorGUILayout.Toggle(Styles.showFailedCheckouts,
                                                                                   EditorUserSettings.showFailedCheckout);
                    EditorUserSettings.overwriteFailedCheckoutAssets = EditorGUILayout.Toggle(
                        Styles.overwriteFailedCheckoutAssets, EditorUserSettings.overwriteFailedCheckoutAssets);
                }

                EditorUserSettings.semanticMergeMode = (SemanticMergeMode)EditorGUILayout.Popup(Styles.smartMerge,
                                                                                                (int)EditorUserSettings.semanticMergeMode, semanticMergePopupList);

                GUILayout.Space(10);
                GUILayout.Label(Styles.overlayIcons);

                EditorGUI.indentLevel++;
                var newProjectOverlayIcons = EditorGUILayout.Toggle(Styles.projectOverlayIcons, EditorUserSettings.overlayIcons);
                if (newProjectOverlayIcons != EditorUserSettings.overlayIcons)
                {
                    EditorUserSettings.overlayIcons = newProjectOverlayIcons;
                    EditorApplication.RequestRepaintAllViews();
                }

                var newHierarchyOverlayIcons = EditorGUILayout.Toggle(Styles.hierarchyOverlayIcons, EditorUserSettings.hierarchyOverlayIcons);
                if (newHierarchyOverlayIcons != EditorUserSettings.hierarchyOverlayIcons)
                {
                    EditorUserSettings.hierarchyOverlayIcons = newHierarchyOverlayIcons;
                    EditorApplication.RequestRepaintAllViews();
                }

                var newOtherOverlayIcons = EditorGUILayout.Toggle(Styles.otherOverlayIcons, EditorUserSettings.otherOverlayIcons);
                if (newOtherOverlayIcons != EditorUserSettings.otherOverlayIcons)
                {
                    EditorUserSettings.otherOverlayIcons = newOtherOverlayIcons;
                    EditorApplication.RequestRepaintAllViews();
                }
                EditorGUI.indentLevel--;
                GUILayout.Space(10);

                GUI.enabled = true;
                if (newProjectOverlayIcons || newHierarchyOverlayIcons || newOtherOverlayIcons)
                {
                    DrawOverlayDescriptions();
                }
            }
            GUILayout.EndVertical();
        }
Example #19
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            // GUI.enabled hack because we don't want some controls to be disabled if the EditorSettings.asset is locked
            // since some of the controls are not dependent on the Editor Settings asset. Unfortunately, this assumes
            // that the editor will only be disabled because of version control locking which may change in the future.
            var editorEnabled = GUI.enabled;

            // Remove Settings are taken from preferences and NOT from the EditorSettings Asset.
            // Only show them when editing the "global" settings
            if (m_IsGlobalSettings)
            {
                ShowUnityRemoteGUI(editorEnabled);
            }

            bool collabEnabled = Collab.instance.IsCollabEnabledForCurrentProject();

            GUILayout.Space(10);

            int index = m_SerializationMode.intValue;

            using (new EditorGUI.DisabledScope(!collabEnabled))
            {
                GUI.enabled = !collabEnabled;
                GUILayout.Label(Content.assetSerialization, EditorStyles.boldLabel);
                GUI.enabled = editorEnabled && !collabEnabled;
                CreatePopupMenu("Mode", serializationPopupList, index, SetAssetSerializationMode);
            }
            if (collabEnabled)
            {
                EditorGUILayout.HelpBox("Asset Serialization is forced to Text when using Collaboration feature.", MessageType.Warning);
            }

            if (m_SerializationMode.intValue != (int)SerializationMode.ForceBinary)
            {
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(m_SerializeInlineMappingsOnOneLine);
                if (EditorGUI.EndChangeCheck() && m_IsGlobalSettings)
                {
                    EditorSettings.serializeInlineMappingsOnOneLine = m_SerializeInlineMappingsOnOneLine.boolValue;
                }
            }

            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label(Content.defaultBehaviorMode, EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            index = Mathf.Clamp(m_DefaultBehaviorMode.intValue, 0, behaviorPopupList.Length - 1);
            CreatePopupMenu(Content.mode.text, behaviorPopupList, index, SetDefaultBehaviorMode);

            // CacheServer is part asset and preferences. Only show UI in case of Global Settings editing.
            if (m_IsGlobalSettings)
            {
                var wasEnabled = GUI.enabled;
                GUI.enabled = true;

                DoCacheServerSettings();

                GUI.enabled = wasEnabled;
            }

            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label("Prefab Editing Environments", EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            {
                EditorGUI.BeginChangeCheck();
                var scene = m_PrefabRegularEnvironment.objectReferenceValue as SceneAsset;
                scene = (SceneAsset)EditorGUILayout.ObjectField("Regular Environment", scene, typeof(SceneAsset), false);
                if (EditorGUI.EndChangeCheck())
                {
                    m_PrefabRegularEnvironment.objectReferenceValue = scene;
                    if (m_IsGlobalSettings)
                    {
                        EditorSettings.prefabRegularEnvironment = scene;
                    }
                }
            }
            {
                EditorGUI.BeginChangeCheck();
                var scene = m_PrefabUIEnvironment.objectReferenceValue as SceneAsset;
                scene = (SceneAsset)EditorGUILayout.ObjectField("UI Environment", scene, typeof(SceneAsset), false);
                if (EditorGUI.EndChangeCheck())
                {
                    m_PrefabUIEnvironment.objectReferenceValue = scene;
                    if (m_IsGlobalSettings)
                    {
                        EditorSettings.prefabUIEnvironment = scene;
                    }
                }
            }

            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label(Content.graphics, EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            if (m_IsGlobalSettings)
            {
                EditorGUI.BeginChangeCheck();
                bool showRes = LightmapVisualization.showResolution;
                showRes = EditorGUILayout.Toggle(Content.showLightmapResolutionOverlay, showRes);
                if (EditorGUI.EndChangeCheck())
                {
                    LightmapVisualization.showResolution = showRes;
                }
            }

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(m_UseLegacyProbeSampleCount, Content.useLegacyProbeSampleCount);
            if (EditorGUI.EndChangeCheck())
            {
                if (m_IsGlobalSettings)
                {
                    EditorSettings.useLegacyProbeSampleCount = m_UseLegacyProbeSampleCount.boolValue;
                }

                EditorApplication.RequestRepaintAllViews();
            }

            var rect = EditorGUILayout.GetControlRect();

            EditorGUI.BeginProperty(rect, Content.enableCookiesInLightmapper, m_DisableCookiesInLightmapper);
            EditorGUI.BeginChangeCheck();
            bool enableCookiesInLightmapperValue = !m_DisableCookiesInLightmapper.boolValue;

            enableCookiesInLightmapperValue = EditorGUI.Toggle(rect, Content.enableCookiesInLightmapper, enableCookiesInLightmapperValue);
            if (EditorGUI.EndChangeCheck())
            {
                m_DisableCookiesInLightmapper.boolValue = !enableCookiesInLightmapperValue;

                if (m_IsGlobalSettings)
                {
                    EditorSettings.enableCookiesInLightmapper = enableCookiesInLightmapperValue;
                }

                EditorApplication.RequestRepaintAllViews();
            }
            EditorGUI.EndProperty();

            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label(Content.spritePacker, EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            // Legacy Packer has been deprecated.
            index = Mathf.Clamp(m_SpritePackerMode.intValue - spritePackDeprecatedEnums, 0, spritePackerPopupList.Length - 1);
            CreatePopupMenu(Content.mode.text, spritePackerPopupList, index, SetSpritePackerMode);

            if (m_SpritePackerMode.intValue == (int)SpritePackerMode.SpriteAtlasV2)
            {
                var message = "Sprite Atlas V2 (Experimental) supports CacheServer with Importer workflow. Please take a backup of your project before switching to V2.";
                EditorGUILayout.HelpBox(message, MessageType.Info, true);
            }

            DoProjectGenerationSettings();
            DoEtcTextureCompressionSettings();
            DoLineEndingsSettings();
            DoStreamingSettings();
            DoShaderCompilationSettings();
            DoEnterPlayModeSettings();

            serializedObject.ApplyModifiedProperties();
        }
Example #20
0
        public override void OnInspectorGUI()
        {
            // ISSUE: object of a compiler-generated type is created
            // ISSUE: variable of a compiler-generated type
            EditorSettingsInspector.\u003COnInspectorGUI\u003Ec__AnonStorey8F guICAnonStorey8F = new EditorSettingsInspector.\u003COnInspectorGUI\u003Ec__AnonStorey8F();
            bool enabled = GUI.enabled;

            this.ShowUnityRemoteGUI(enabled);
            GUILayout.Space(10f);
            GUI.enabled = true;
            GUILayout.Label("Version Control", EditorStyles.boldLabel, new GUILayoutOption[0]);
            GUI.enabled = enabled;
            // ISSUE: reference to a compiler-generated field
            guICAnonStorey8F.selvc = (ExternalVersionControl)EditorSettings.externalVersionControl;
            // ISSUE: reference to a compiler-generated method
            int selectedIndex1 = Array.FindIndex <EditorSettingsInspector.PopupElement>(this.vcPopupList, new Predicate <EditorSettingsInspector.PopupElement>(guICAnonStorey8F.\u003C\u003Em__15E));

            if (selectedIndex1 < 0)
            {
                selectedIndex1 = 0;
            }
            GUIContent content1 = new GUIContent(this.vcPopupList[selectedIndex1].content);
            Rect       rect1    = EditorGUI.PrefixLabel(GUILayoutUtility.GetRect(content1, EditorStyles.popup), 0, new GUIContent("Mode"));

            if (EditorGUI.ButtonMouseDown(rect1, content1, FocusType.Passive, EditorStyles.popup))
            {
                this.DoPopup(rect1, this.vcPopupList, selectedIndex1, new GenericMenu.MenuFunction2(this.SetVersionControlSystem));
            }
            if (this.VersionControlSystemHasGUI())
            {
                // ISSUE: object of a compiler-generated type is created
                // ISSUE: variable of a compiler-generated type
                EditorSettingsInspector.\u003COnInspectorGUI\u003Ec__AnonStorey90 guICAnonStorey90 = new EditorSettingsInspector.\u003COnInspectorGUI\u003Ec__AnonStorey90();
                GUI.enabled = true;
                bool flag1 = false;
                if (EditorSettings.externalVersionControl == ExternalVersionControl.AssetServer)
                {
                    EditorUserSettings.SetConfigValue("vcUsername", EditorGUILayout.TextField("User", EditorUserSettings.GetConfigValue("vcUsername"), new GUILayoutOption[0]));
                    EditorUserSettings.SetConfigValue("vcPassword", EditorGUILayout.PasswordField("Password", EditorUserSettings.GetConfigValue("vcPassword"), new GUILayoutOption[0]));
                }
                else if (!(EditorSettings.externalVersionControl == ExternalVersionControl.Generic) && !(EditorSettings.externalVersionControl == ExternalVersionControl.Disabled))
                {
                    ConfigField[] activeConfigFields = Provider.GetActiveConfigFields();
                    flag1 = true;
                    foreach (ConfigField configField in activeConfigFields)
                    {
                        string configValue = EditorUserSettings.GetConfigValue(configField.name);
                        string str         = !configField.isPassword ? EditorGUILayout.TextField(configField.label, configValue, new GUILayoutOption[0]) : EditorGUILayout.PasswordField(configField.label, configValue, new GUILayoutOption[0]);
                        if (str != configValue)
                        {
                            EditorUserSettings.SetConfigValue(configField.name, str);
                        }
                        if (configField.isRequired && string.IsNullOrEmpty(str))
                        {
                            flag1 = false;
                        }
                    }
                }
                // ISSUE: reference to a compiler-generated field
                guICAnonStorey90.logLevel = EditorUserSettings.GetConfigValue("vcSharedLogLevel");
                // ISSUE: reference to a compiler-generated method
                int index1 = Array.FindIndex <string>(this.logLevelPopupList, new Predicate <string>(guICAnonStorey90.\u003C\u003Em__15F));
                if (index1 == -1)
                {
                    // ISSUE: reference to a compiler-generated field
                    guICAnonStorey90.logLevel = "info";
                }
                int index2 = EditorGUILayout.Popup("Log Level", Math.Abs(index1), this.logLevelPopupList, new GUILayoutOption[0]);
                if (index2 != index1)
                {
                    EditorUserSettings.SetConfigValue("vcSharedLogLevel", this.logLevelPopupList[index2].ToLower());
                }
                GUI.enabled = enabled;
                string label2 = "Connected";
                if (Provider.onlineState == OnlineState.Updating)
                {
                    label2 = "Connecting...";
                }
                else if (Provider.onlineState == OnlineState.Offline)
                {
                    label2 = "Disconnected";
                }
                EditorGUILayout.LabelField("Status", label2, new GUILayoutOption[0]);
                if (Provider.onlineState != OnlineState.Online && !string.IsNullOrEmpty(Provider.offlineReason))
                {
                    GUI.enabled = false;
                    GUILayout.TextArea(Provider.offlineReason);
                    GUI.enabled = enabled;
                }
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUI.enabled = flag1;
                if (GUILayout.Button("Connect", EditorStyles.miniButton, new GUILayoutOption[0]))
                {
                    Provider.UpdateSettings();
                }
                GUILayout.EndHorizontal();
                EditorUserSettings.AutomaticAdd = EditorGUILayout.Toggle("Automatic add", EditorUserSettings.AutomaticAdd, new GUILayoutOption[0]);
                if (Provider.requiresNetwork)
                {
                    bool flag2 = EditorGUILayout.Toggle("Work Offline", EditorUserSettings.WorkOffline, new GUILayoutOption[0]);
                    if (flag2 != EditorUserSettings.WorkOffline)
                    {
                        if (flag2 && !EditorUtility.DisplayDialog("Confirm working offline", "Working offline and making changes to your assets means that you will have to manually integrate changes back into version control using your standard version control client before you stop working offline in Unity. Make sure you know what you are doing.", "Work offline", "Cancel"))
                        {
                            flag2 = false;
                        }
                        EditorUserSettings.WorkOffline = flag2;
                        EditorApplication.RequestRepaintAllViews();
                    }
                }
                if (Provider.hasCheckoutSupport)
                {
                    EditorUserSettings.showFailedCheckout = EditorGUILayout.Toggle("Show failed checkouts", EditorUserSettings.showFailedCheckout, new GUILayoutOption[0]);
                }
                GUI.enabled = enabled;
                EditorUserSettings.semanticMergeMode = (SemanticMergeMode)EditorGUILayout.Popup("Smart merge", (int)EditorUserSettings.semanticMergeMode, this.semanticMergePopupList, new GUILayoutOption[0]);
                this.DrawOverlayDescriptions();
            }
            GUILayout.Space(10f);
            GUILayout.Label("WWW Security Emulation", EditorStyles.boldLabel, new GUILayoutOption[0]);
            EditorSettings.webSecurityEmulationEnabled = EditorGUILayout.Toggle("Enable Webplayer Security Emulation", EditorSettings.webSecurityEmulationEnabled, new GUILayoutOption[0]);
            string str1 = EditorGUILayout.TextField("Host URL", EditorSettings.webSecurityEmulationHostUrl, new GUILayoutOption[0]);

            if (str1 != EditorSettings.webSecurityEmulationHostUrl)
            {
                EditorSettings.webSecurityEmulationHostUrl = str1;
            }
            GUILayout.Space(10f);
            GUI.enabled = true;
            GUILayout.Label("Asset Serialization", EditorStyles.boldLabel, new GUILayoutOption[0]);
            GUI.enabled = enabled;
            GUIContent content2 = new GUIContent(this.serializationPopupList[(int)EditorSettings.serializationMode].content);
            Rect       rect2    = EditorGUI.PrefixLabel(GUILayoutUtility.GetRect(content2, EditorStyles.popup), 0, new GUIContent("Mode"));

            if (EditorGUI.ButtonMouseDown(rect2, content2, FocusType.Passive, EditorStyles.popup))
            {
                this.DoPopup(rect2, this.serializationPopupList, (int)EditorSettings.serializationMode, new GenericMenu.MenuFunction2(this.SetAssetSerializationMode));
            }
            GUILayout.Space(10f);
            GUI.enabled = true;
            GUILayout.Label("Default Behavior Mode", EditorStyles.boldLabel, new GUILayoutOption[0]);
            GUI.enabled = enabled;
            int        selectedIndex2 = Mathf.Clamp((int)EditorSettings.defaultBehaviorMode, 0, this.behaviorPopupList.Length - 1);
            GUIContent content3       = new GUIContent(this.behaviorPopupList[selectedIndex2].content);
            Rect       rect3          = EditorGUI.PrefixLabel(GUILayoutUtility.GetRect(content3, EditorStyles.popup), 0, new GUIContent("Mode"));

            if (EditorGUI.ButtonMouseDown(rect3, content3, FocusType.Passive, EditorStyles.popup))
            {
                this.DoPopup(rect3, this.behaviorPopupList, selectedIndex2, new GenericMenu.MenuFunction2(this.SetDefaultBehaviorMode));
            }
            GUILayout.Space(10f);
            GUI.enabled = true;
            GUILayout.Label("Sprite Packer", EditorStyles.boldLabel, new GUILayoutOption[0]);
            GUI.enabled = enabled;
            int        selectedIndex3 = Mathf.Clamp((int)EditorSettings.spritePackerMode, 0, this.spritePackerPopupList.Length - 1);
            GUIContent content4       = new GUIContent(this.spritePackerPopupList[selectedIndex3].content);
            Rect       rect4          = EditorGUI.PrefixLabel(GUILayoutUtility.GetRect(content4, EditorStyles.popup), 0, new GUIContent("Mode"));

            if (EditorGUI.ButtonMouseDown(rect4, content4, FocusType.Passive, EditorStyles.popup))
            {
                this.DoPopup(rect4, this.spritePackerPopupList, selectedIndex3, new GenericMenu.MenuFunction2(this.SetSpritePackerMode));
            }
            int        selectedIndex4 = Mathf.Clamp(EditorSettings.spritePackerPaddingPower - 1, 0, 2);
            GUIContent content5       = new GUIContent(this.spritePackerPaddingPowerPopupList[selectedIndex4].content);
            Rect       rect5          = EditorGUI.PrefixLabel(GUILayoutUtility.GetRect(content5, EditorStyles.popup), 0, new GUIContent("Padding Power"));

            if (EditorGUI.ButtonMouseDown(rect5, content5, FocusType.Passive, EditorStyles.popup))
            {
                this.DoPopup(rect5, this.spritePackerPaddingPowerPopupList, selectedIndex4, new GenericMenu.MenuFunction2(this.SetSpritePackerPaddingPower));
            }
            this.DoProjectGenerationSettings();
        }
        public override void OnInspectorGUI()
        {
            bool enabled = GUI.enabled;

            this.ShowUnityRemoteGUI(enabled);
            GUILayout.Space(10f);
            GUI.enabled = true;
            GUILayout.Label("Version Control", EditorStyles.boldLabel, new GUILayoutOption[0]);
            GUI.enabled = enabled;
            ExternalVersionControl selvc = EditorSettings.externalVersionControl;
            int num = Array.FindIndex <EditorSettingsInspector.PopupElement>(this.vcPopupList, (EditorSettingsInspector.PopupElement cand) => cand.content.text == selvc);

            if (num < 0)
            {
                num = 0;
            }
            GUIContent content = new GUIContent(this.vcPopupList[num].content);
            Rect       rect    = GUILayoutUtility.GetRect(content, EditorStyles.popup);

            rect = EditorGUI.PrefixLabel(rect, 0, new GUIContent("Mode"));
            if (EditorGUI.ButtonMouseDown(rect, content, FocusType.Passive, EditorStyles.popup))
            {
                this.DoPopup(rect, this.vcPopupList, num, new GenericMenu.MenuFunction2(this.SetVersionControlSystem));
            }
            if (this.VersionControlSystemHasGUI())
            {
                GUI.enabled = true;
                bool enabled2 = false;
                if (EditorSettings.externalVersionControl == ExternalVersionControl.AssetServer)
                {
                    EditorUserSettings.SetConfigValue("vcUsername", EditorGUILayout.TextField("User", EditorUserSettings.GetConfigValue("vcUsername"), new GUILayoutOption[0]));
                    EditorUserSettings.SetConfigValue("vcPassword", EditorGUILayout.PasswordField("Password", EditorUserSettings.GetConfigValue("vcPassword"), new GUILayoutOption[0]));
                }
                else if (!(EditorSettings.externalVersionControl == ExternalVersionControl.Generic))
                {
                    if (!(EditorSettings.externalVersionControl == ExternalVersionControl.Disabled))
                    {
                        ConfigField[] activeConfigFields = Provider.GetActiveConfigFields();
                        enabled2 = true;
                        ConfigField[] array = activeConfigFields;
                        for (int i = 0; i < array.Length; i++)
                        {
                            ConfigField configField = array[i];
                            string      configValue = EditorUserSettings.GetConfigValue(configField.name);
                            string      text;
                            if (configField.isPassword)
                            {
                                text = EditorGUILayout.PasswordField(configField.label, configValue, new GUILayoutOption[0]);
                            }
                            else
                            {
                                text = EditorGUILayout.TextField(configField.label, configValue, new GUILayoutOption[0]);
                            }
                            if (text != configValue)
                            {
                                EditorUserSettings.SetConfigValue(configField.name, text);
                            }
                            if (configField.isRequired && string.IsNullOrEmpty(text))
                            {
                                enabled2 = false;
                            }
                        }
                    }
                }
                string logLevel = EditorUserSettings.GetConfigValue("vcSharedLogLevel");
                int    num2     = Array.FindIndex <string>(this.logLevelPopupList, (string item) => item.ToLower() == logLevel);
                if (num2 == -1)
                {
                    logLevel = "info";
                }
                int num3 = EditorGUILayout.Popup("Log Level", Math.Abs(num2), this.logLevelPopupList, new GUILayoutOption[0]);
                if (num3 != num2)
                {
                    EditorUserSettings.SetConfigValue("vcSharedLogLevel", this.logLevelPopupList[num3].ToLower());
                }
                GUI.enabled = enabled;
                string label = "Connected";
                if (Provider.onlineState == OnlineState.Updating)
                {
                    label = "Connecting...";
                }
                else if (Provider.onlineState == OnlineState.Offline)
                {
                    label = "Disconnected";
                }
                EditorGUILayout.LabelField("Status", label, new GUILayoutOption[0]);
                if (Provider.onlineState != OnlineState.Online && !string.IsNullOrEmpty(Provider.offlineReason))
                {
                    GUI.enabled = false;
                    GUILayout.TextArea(Provider.offlineReason, new GUILayoutOption[0]);
                    GUI.enabled = enabled;
                }
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.FlexibleSpace();
                GUI.enabled = enabled2;
                if (GUILayout.Button("Connect", EditorStyles.miniButton, new GUILayoutOption[0]))
                {
                    Provider.UpdateSettings();
                }
                GUILayout.EndHorizontal();
                EditorUserSettings.AutomaticAdd = EditorGUILayout.Toggle("Automatic add", EditorUserSettings.AutomaticAdd, new GUILayoutOption[0]);
                if (Provider.requiresNetwork)
                {
                    bool flag = EditorGUILayout.Toggle("Work Offline", EditorUserSettings.WorkOffline, new GUILayoutOption[0]);
                    if (flag != EditorUserSettings.WorkOffline)
                    {
                        if (flag && !EditorUtility.DisplayDialog("Confirm working offline", "Working offline and making changes to your assets means that you will have to manually integrate changes back into version control using your standard version control client before you stop working offline in Unity. Make sure you know what you are doing.", "Work offline", "Cancel"))
                        {
                            flag = false;
                        }
                        EditorUserSettings.WorkOffline = flag;
                        EditorApplication.RequestRepaintAllViews();
                    }
                }
                if (Provider.hasCheckoutSupport)
                {
                    EditorUserSettings.showFailedCheckout = EditorGUILayout.Toggle("Show failed checkouts", EditorUserSettings.showFailedCheckout, new GUILayoutOption[0]);
                }
                GUI.enabled = enabled;
                EditorUserSettings.semanticMergeMode = (SemanticMergeMode)EditorGUILayout.Popup("Smart merge", (int)EditorUserSettings.semanticMergeMode, this.semanticMergePopupList, new GUILayoutOption[0]);
                this.DrawOverlayDescriptions();
            }
            GUILayout.Space(10f);
            GUILayout.Label("WWW Security Emulation", EditorStyles.boldLabel, new GUILayoutOption[0]);
            EditorSettings.webSecurityEmulationEnabled = EditorGUILayout.Toggle("Enable Webplayer Security Emulation", EditorSettings.webSecurityEmulationEnabled, new GUILayoutOption[0]);
            string text2 = EditorGUILayout.TextField("Host URL", EditorSettings.webSecurityEmulationHostUrl, new GUILayoutOption[0]);

            if (text2 != EditorSettings.webSecurityEmulationHostUrl)
            {
                EditorSettings.webSecurityEmulationHostUrl = text2;
            }
            GUILayout.Space(10f);
            GUI.enabled = true;
            GUILayout.Label("Asset Serialization", EditorStyles.boldLabel, new GUILayoutOption[0]);
            GUI.enabled = enabled;
            content     = new GUIContent(this.serializationPopupList[(int)EditorSettings.serializationMode].content);
            rect        = GUILayoutUtility.GetRect(content, EditorStyles.popup);
            rect        = EditorGUI.PrefixLabel(rect, 0, new GUIContent("Mode"));
            if (EditorGUI.ButtonMouseDown(rect, content, FocusType.Passive, EditorStyles.popup))
            {
                this.DoPopup(rect, this.serializationPopupList, (int)EditorSettings.serializationMode, new GenericMenu.MenuFunction2(this.SetAssetSerializationMode));
            }
            GUILayout.Space(10f);
            GUI.enabled = true;
            GUILayout.Label("Default Behavior Mode", EditorStyles.boldLabel, new GUILayoutOption[0]);
            GUI.enabled = enabled;
            int num4 = Mathf.Clamp((int)EditorSettings.defaultBehaviorMode, 0, this.behaviorPopupList.Length - 1);

            content = new GUIContent(this.behaviorPopupList[num4].content);
            rect    = GUILayoutUtility.GetRect(content, EditorStyles.popup);
            rect    = EditorGUI.PrefixLabel(rect, 0, new GUIContent("Mode"));
            if (EditorGUI.ButtonMouseDown(rect, content, FocusType.Passive, EditorStyles.popup))
            {
                this.DoPopup(rect, this.behaviorPopupList, num4, new GenericMenu.MenuFunction2(this.SetDefaultBehaviorMode));
            }
            GUILayout.Space(10f);
            GUI.enabled = true;
            GUILayout.Label("Sprite Packer", EditorStyles.boldLabel, new GUILayoutOption[0]);
            GUI.enabled = enabled;
            num4        = Mathf.Clamp((int)EditorSettings.spritePackerMode, 0, this.spritePackerPopupList.Length - 1);
            content     = new GUIContent(this.spritePackerPopupList[num4].content);
            rect        = GUILayoutUtility.GetRect(content, EditorStyles.popup);
            rect        = EditorGUI.PrefixLabel(rect, 0, new GUIContent("Mode"));
            if (EditorGUI.ButtonMouseDown(rect, content, FocusType.Passive, EditorStyles.popup))
            {
                this.DoPopup(rect, this.spritePackerPopupList, num4, new GenericMenu.MenuFunction2(this.SetSpritePackerMode));
            }
            num4    = Mathf.Clamp(EditorSettings.spritePackerPaddingPower - 1, 0, 2);
            content = new GUIContent(this.spritePackerPaddingPowerPopupList[num4].content);
            rect    = GUILayoutUtility.GetRect(content, EditorStyles.popup);
            rect    = EditorGUI.PrefixLabel(rect, 0, new GUIContent("Padding Power"));
            if (EditorGUI.ButtonMouseDown(rect, content, FocusType.Passive, EditorStyles.popup))
            {
                this.DoPopup(rect, this.spritePackerPaddingPowerPopupList, num4, new GenericMenu.MenuFunction2(this.SetSpritePackerPaddingPower));
            }
            this.DoProjectGenerationSettings();
        }
Example #22
0
        public override void OnInspectorGUI()
        {
            // GUI.enabled hack because we don't want some controls to be disabled if the EditorSettings.asset is locked
            // since some of the controls are not dependent on the Editor Settings asset. Unfortunately, this assumes
            // that the editor will only be disabled because of version control locking which may change in the future.
            var editorEnabled = GUI.enabled;

            ShowUnityRemoteGUI(editorEnabled);

            GUILayout.Space(10);
            bool collabEnabled = Collab.instance.IsCollabEnabledForCurrentProject();

            using (new EditorGUI.DisabledScope(!collabEnabled))
            {
                GUI.enabled = !collabEnabled;
                GUILayout.Label("Version Control", EditorStyles.boldLabel);

                ExternalVersionControl selvc = EditorSettings.externalVersionControl;
                CreatePopupMenuVersionControl("Mode", vcPopupList, selvc, SetVersionControlSystem);
                GUI.enabled = editorEnabled && !collabEnabled;
            }
            if (collabEnabled)
            {
                EditorGUILayout.HelpBox("Version Control not available when using Collaboration feature.", MessageType.Warning);
            }

            if (VersionControlSystemHasGUI())
            {
                GUI.enabled = true;
                bool hasRequiredFields = false;

                if (EditorSettings.externalVersionControl == ExternalVersionControl.Generic ||
                    EditorSettings.externalVersionControl == ExternalVersionControl.Disabled)
                {
                    // no specific UI for these VCS types
                }
                else
                {
                    ConfigField[] configFields = Provider.GetActiveConfigFields();

                    hasRequiredFields = true;

                    foreach (ConfigField field in configFields)
                    {
                        string newVal;
                        string oldVal = EditorUserSettings.GetConfigValue(field.name);
                        if (field.isPassword)
                        {
                            newVal = EditorGUILayout.PasswordField(field.label, oldVal);
                            if (newVal != oldVal)
                            {
                                EditorUserSettings.SetPrivateConfigValue(field.name, newVal);
                            }
                        }
                        else
                        {
                            newVal = EditorGUILayout.TextField(field.label, oldVal);
                            if (newVal != oldVal)
                            {
                                EditorUserSettings.SetConfigValue(field.name, newVal);
                            }
                        }

                        if (field.isRequired && string.IsNullOrEmpty(newVal))
                        {
                            hasRequiredFields = false;
                        }
                    }
                }

                // Log level popup
                string logLevel = EditorUserSettings.GetConfigValue("vcSharedLogLevel");
                int    idx      = System.Array.FindIndex(logLevelPopupList, (item) => item.ToLower() == logLevel);
                if (idx == -1)
                {
                    logLevel = "notice";
                    idx      = System.Array.FindIndex(logLevelPopupList, (item) => item.ToLower() == logLevel);
                    if (idx == -1)
                    {
                        idx = 0;
                    }
                    logLevel = logLevelPopupList[idx];
                    EditorUserSettings.SetConfigValue("vcSharedLogLevel", logLevel);
                }
                int newIdx = EditorGUILayout.Popup("Log Level", idx, logLevelPopupList);
                if (newIdx != idx)
                {
                    EditorUserSettings.SetConfigValue("vcSharedLogLevel", logLevelPopupList[newIdx].ToLower());
                }

                GUI.enabled = editorEnabled;

                string osState = "Connected";
                if (Provider.onlineState == OnlineState.Updating)
                {
                    osState = "Connecting...";
                }
                else if (Provider.onlineState == OnlineState.Offline)
                {
                    osState = "Disconnected";
                }

                EditorGUILayout.LabelField("Status", osState);

                if (Provider.onlineState != OnlineState.Online && !string.IsNullOrEmpty(Provider.offlineReason))
                {
                    GUI.enabled = false;
                    GUILayout.TextArea(Provider.offlineReason);
                    GUI.enabled = editorEnabled;
                }

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUI.enabled = hasRequiredFields && Provider.onlineState != OnlineState.Updating;
                if (GUILayout.Button("Connect", EditorStyles.miniButton))
                {
                    Provider.UpdateSettings();
                }
                GUILayout.EndHorizontal();

                EditorUserSettings.AutomaticAdd = EditorGUILayout.Toggle("Automatic add", EditorUserSettings.AutomaticAdd);

                if (Provider.requiresNetwork)
                {
                    bool workOfflineNew = EditorGUILayout.Toggle("Work Offline", EditorUserSettings.WorkOffline); // Enabled has a slightly different behaviour
                    if (workOfflineNew != EditorUserSettings.WorkOffline)
                    {
                        // On toggling on show a warning
                        if (workOfflineNew && !EditorUtility.DisplayDialog("Confirm working offline", "Working offline and making changes to your assets means that you will have to manually integrate changes back into version control using your standard version control client before you stop working offline in Unity. Make sure you know what you are doing.", "Work offline", "Cancel"))
                        {
                            workOfflineNew = false; // User cancelled working offline
                        }
                        EditorUserSettings.WorkOffline = workOfflineNew;
                        EditorApplication.RequestRepaintAllViews();
                    }

                    EditorUserSettings.allowAsyncStatusUpdate = EditorGUILayout.Toggle("Allow Async Update", EditorUserSettings.allowAsyncStatusUpdate);
                }

                if (Provider.hasCheckoutSupport)
                {
                    EditorUserSettings.showFailedCheckout = EditorGUILayout.Toggle("Show failed checkouts", EditorUserSettings.showFailedCheckout);
                }

                GUI.enabled = editorEnabled;

                // Semantic merge popup
                EditorUserSettings.semanticMergeMode = (SemanticMergeMode)EditorGUILayout.Popup("Smart merge", (int)EditorUserSettings.semanticMergeMode, semanticMergePopupList);

                DrawOverlayDescriptions();
            }

            GUILayout.Space(10);

            int index = (int)EditorSettings.serializationMode;

            using (new EditorGUI.DisabledScope(!collabEnabled))
            {
                GUI.enabled = !collabEnabled;
                GUILayout.Label("Asset Serialization", EditorStyles.boldLabel);
                GUI.enabled = editorEnabled && !collabEnabled;


                CreatePopupMenu("Mode", serializationPopupList, index, SetAssetSerializationMode);
            }
            if (collabEnabled)
            {
                EditorGUILayout.HelpBox("Asset Serialization is forced to Text when using Collaboration feature.", MessageType.Warning);
            }

            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label("Default Behavior Mode", EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            index = Mathf.Clamp((int)EditorSettings.defaultBehaviorMode, 0, behaviorPopupList.Length - 1);
            CreatePopupMenu("Mode", behaviorPopupList, index, SetDefaultBehaviorMode);

            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label("Sprite Packer", EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            index = Mathf.Clamp((int)EditorSettings.spritePackerMode, 0, spritePackerPopupList.Length - 1);
            CreatePopupMenu("Mode", spritePackerPopupList, index, SetSpritePackerMode);

            if (EditorSettings.spritePackerMode == SpritePackerMode.AlwaysOn ||
                EditorSettings.spritePackerMode == SpritePackerMode.BuildTimeOnly)
            {
                index = Mathf.Clamp((int)(EditorSettings.spritePackerPaddingPower - 1), 0, 2);
                CreatePopupMenu("Padding Power (Legacy Sprite Packer)", spritePackerPaddingPowerPopupList, index, SetSpritePackerPaddingPower);
            }

            DoProjectGenerationSettings();
            DoEtcTextureCompressionSettings();
            DoInternalSettings();
            DoLineEndingsSettings();
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            // GUI.enabled hack because we don't want some controls to be disabled if the EditorSettings.asset is locked
            // since some of the controls are not dependent on the Editor Settings asset. Unfortunately, this assumes
            // that the editor will only be disabled because of version control locking which may change in the future.
            var editorEnabled = GUI.enabled;

            ShowUnityRemoteGUI(editorEnabled);

            bool collabEnabled = Collab.instance.IsCollabEnabledForCurrentProject();

            GUILayout.Space(10);

            int index = (int)EditorSettings.serializationMode;

            using (new EditorGUI.DisabledScope(!collabEnabled))
            {
                GUI.enabled = !collabEnabled;
                GUILayout.Label(Content.assetSerialization, EditorStyles.boldLabel);
                GUI.enabled = editorEnabled && !collabEnabled;


                CreatePopupMenu("Mode", serializationPopupList, index, SetAssetSerializationMode);
            }
            if (collabEnabled)
            {
                EditorGUILayout.HelpBox("Asset Serialization is forced to Text when using Collaboration feature.", MessageType.Warning);
            }

            if (EditorSettings.serializationMode != SerializationMode.ForceBinary)
            {
                EditorSettings.serializeInlineMappingsOnOneLine = EditorGUILayout.Toggle(Content.textSerializeMappingsOnOneLine, EditorSettings.serializeInlineMappingsOnOneLine);
            }

            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label(Content.defaultBehaviorMode, EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            index = Mathf.Clamp((int)EditorSettings.defaultBehaviorMode, 0, behaviorPopupList.Length - 1);
            CreatePopupMenu(Content.mode.text, behaviorPopupList, index, SetDefaultBehaviorMode);

            {
                var wasEnabled = GUI.enabled;
                GUI.enabled = true;

                DoAssetPipelineSettings();

                if (EditorSettings.assetPipelineMode == AssetPipelineMode.Version2)
                {
                    DoCacheServerSettings();
                }

                GUI.enabled = wasEnabled;
            }
            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label("Prefab Editing Environments", EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            {
                EditorGUI.BeginChangeCheck();
                SceneAsset scene = EditorSettings.prefabRegularEnvironment;
                scene = (SceneAsset)EditorGUILayout.ObjectField("Regular Environment", scene, typeof(SceneAsset), false);
                if (EditorGUI.EndChangeCheck())
                {
                    EditorSettings.prefabRegularEnvironment = scene;
                }
            }
            {
                EditorGUI.BeginChangeCheck();
                SceneAsset scene = EditorSettings.prefabUIEnvironment;
                scene = (SceneAsset)EditorGUILayout.ObjectField("UI Environment", scene, typeof(SceneAsset), false);
                if (EditorGUI.EndChangeCheck())
                {
                    EditorSettings.prefabUIEnvironment = scene;
                }
            }

            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label(Content.graphics, EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            EditorGUI.BeginChangeCheck();
            bool showRes = LightmapVisualization.showResolution;

            showRes = EditorGUILayout.Toggle(Content.showLightmapResolutionOverlay, showRes);
            if (EditorGUI.EndChangeCheck())
            {
                LightmapVisualization.showResolution = showRes;
            }

            EditorGUI.BeginChangeCheck();
            bool useLegacyProbeSampleCountValue = EditorSettings.useLegacyProbeSampleCount;

            useLegacyProbeSampleCountValue = EditorGUILayout.Toggle(Content.useLegacyProbeSampleCount, useLegacyProbeSampleCountValue);
            if (EditorGUI.EndChangeCheck())
            {
                EditorApplication.RequestRepaintAllViews();
                EditorSettings.useLegacyProbeSampleCount = useLegacyProbeSampleCountValue;
            }

            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label(Content.spritePacker, EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            index = Mathf.Clamp((int)EditorSettings.spritePackerMode, 0, spritePackerPopupList.Length - 1);
            CreatePopupMenu(Content.mode.text, spritePackerPopupList, index, SetSpritePackerMode);

            if (EditorSettings.spritePackerMode == SpritePackerMode.SpriteAtlasV2)
            {
                var message = "Sprite Atlas V2 (Experimental) supports CacheServer with Importer workflow. Please take a backup of your project before switching to V2.";
                EditorGUILayout.HelpBox(message, MessageType.Info, true);
            }

            if (EditorSettings.spritePackerMode == SpritePackerMode.AlwaysOn ||
                EditorSettings.spritePackerMode == SpritePackerMode.BuildTimeOnly)
            {
                index = Mathf.Clamp((int)(EditorSettings.spritePackerPaddingPower - 1), 0, 2);
                CreatePopupMenu("Padding Power (Legacy Sprite Packer)", spritePackerPaddingPowerPopupList, index, SetSpritePackerPaddingPower);
            }

            DoProjectGenerationSettings();
            DoEtcTextureCompressionSettings();
            DoLineEndingsSettings();
            DoStreamingSettings();
            DoShaderCompilationSettings();
            DoEnterPlayModeSettings();

            serializedObject.ApplyModifiedProperties();
        }