UnityEditor.CacheServerPreferences.OnGUI C# (CSharp) Method

OnGUI() private method

private OnGUI ( ) : void
return void
        public static void OnGUI()
        {
            EventType type = Event.current.type;
            if (s_Constants == null)
            {
                s_Constants = new Constants();
            }
            GUILayout.Space(10f);
            if (!InternalEditorUtility.HasTeamLicense())
            {
                GUILayout.Label(EditorGUIUtility.TempContent("You need to have a Pro or Team license to use the cache server.", EditorGUIUtility.GetHelpIcon(MessageType.Warning)), EditorStyles.helpBox, new GUILayoutOption[0]);
            }
            using (new EditorGUI.DisabledScope(!InternalEditorUtility.HasTeamLicense()))
            {
                if (!s_PrefsLoaded)
                {
                    ReadPreferences();
                    if ((s_CacheServerMode != CacheServerMode.Disabled) && (s_ConnectionState == ConnectionState.Unknown))
                    {
                        if (InternalEditorUtility.CanConnectToCacheServer())
                        {
                            s_ConnectionState = ConnectionState.Success;
                        }
                        else
                        {
                            s_ConnectionState = ConnectionState.Failure;
                        }
                    }
                    s_PrefsLoaded = true;
                }
                EditorGUI.BeginChangeCheck();
                if (Collab.instance.collabInfo.whitelisted && IsCollabCacheEnabled())
                {
                    s_CollabCacheEnabled = EditorGUILayout.Toggle("Use Collab Cache", s_CollabCacheEnabled, new GUILayoutOption[0]);
                    using (new EditorGUI.DisabledScope(!s_CollabCacheEnabled))
                    {
                        s_CollabCacheIPAddress = EditorGUILayout.TextField("Collab Cache IP Address", s_CollabCacheIPAddress, new GUILayoutOption[0]);
                    }
                }
                s_CacheServerMode = (CacheServerMode) EditorGUILayout.EnumPopup("Cache Server Mode", s_CacheServerMode, new GUILayoutOption[0]);
                if (s_CacheServerMode != CacheServerMode.Remote)
                {
                    goto Label_0238;
                }
                s_CacheServerIPAddress = EditorGUILayout.DelayedTextField("IP Address", s_CacheServerIPAddress, new GUILayoutOption[0]);
                if (GUI.changed)
                {
                    s_ConnectionState = ConnectionState.Unknown;
                }
                GUILayout.Space(5f);
                GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(150f) };
                if (GUILayout.Button("Check Connection", options))
                {
                    if (InternalEditorUtility.CanConnectToCacheServer())
                    {
                        s_ConnectionState = ConnectionState.Success;
                    }
                    else
                    {
                        s_ConnectionState = ConnectionState.Failure;
                    }
                }
                GUILayout.Space(-25f);
                ConnectionState state = s_ConnectionState;
                if (state != ConnectionState.Success)
                {
                    if (state == ConnectionState.Failure)
                    {
                        goto Label_0212;
                    }
                    if (state == ConnectionState.Unknown)
                    {
                        goto Label_0223;
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("Connection successful.", MessageType.Info, false);
                }
                goto Label_041C;
            Label_0212:
                EditorGUILayout.HelpBox("Connection failed.", MessageType.Warning, false);
                goto Label_041C;
            Label_0223:
                GUILayout.Space(44f);
                goto Label_041C;
            Label_0238:
                if (s_CacheServerMode == CacheServerMode.Local)
                {
                    s_LocalCacheServerSize = EditorGUILayout.IntSlider(Styles.maxCacheSize, s_LocalCacheServerSize, 1, 200, new GUILayoutOption[0]);
                    s_EnableCustomPath = EditorGUILayout.Toggle(Styles.customCacheLocation, s_EnableCustomPath, new GUILayoutOption[0]);
                    if (s_EnableCustomPath)
                    {
                        GUIStyle popup = EditorStyles.popup;
                        GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                        EditorGUILayout.PrefixLabel(Styles.cacheFolderLocation, popup);
                        Rect position = GUILayoutUtility.GetRect(GUIContent.none, popup);
                        GUIContent content = !string.IsNullOrEmpty(s_CachePath) ? new GUIContent(s_CachePath) : Styles.browse;
                        if (EditorGUI.ButtonMouseDown(position, content, FocusType.Passive, popup))
                        {
                            string folder = s_CachePath;
                            string str2 = EditorUtility.OpenFolderPanel(Styles.browseCacheLocation.text, folder, "");
                            if (!string.IsNullOrEmpty(str2))
                            {
                                if (LocalCacheServer.CheckValidCacheLocation(str2))
                                {
                                    s_CachePath = str2;
                                    WritePreferences();
                                }
                                else
                                {
                                    EditorUtility.DisplayDialog("Invalid Cache Location", "The directory " + str2 + " contains some files which don't look like Unity Cache server files. Please delete the directory contents or choose another directory.", "OK");
                                }
                            }
                        }
                        GUILayout.EndHorizontal();
                    }
                    else
                    {
                        s_CachePath = "";
                    }
                    GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.Width(120f) };
                    if (GUILayout.Button(Styles.cleanCache, optionArray2))
                    {
                        LocalCacheServer.Clear();
                        s_LocalCacheServerUsedSize = 0L;
                    }
                    if (s_LocalCacheServerUsedSize == -1L)
                    {
                        s_LocalCacheServerUsedSize = FileUtil.GetDirectorySize(LocalCacheServer.GetCacheLocation());
                    }
                    GUILayout.Label(Styles.cacheSizeIs.text + " " + EditorUtility.FormatBytes(s_LocalCacheServerUsedSize), new GUILayoutOption[0]);
                    GUILayout.Label(Styles.cacheFolderLocation.text + ":", new GUILayoutOption[0]);
                    GUILayout.Label(LocalCacheServer.GetCacheLocation(), s_Constants.cacheFolderLocation, new GUILayoutOption[0]);
                }
            Label_041C:
                if (EditorGUI.EndChangeCheck())
                {
                    s_HasPendingChanges = true;
                }
                if ((s_HasPendingChanges && (type == EventType.MouseUp)) || (type == EventType.KeyDown))
                {
                    WritePreferences();
                    ReadPreferences();
                    s_HasPendingChanges = false;
                }
            }
        }