private void OnGUIFooter() { using (new EditorGUIUtility.IconSizeScope(s_IconSize)) { if (AssetDatabaseExperimental.IsCacheServerEnabled()) { // Bad IP:Port. Direct the user to fix in Project Preferences. if (!AssetDatabaseExperimental.CanConnectToCacheServer(AssetDatabaseExperimental.GetCacheServerAddress(), AssetDatabaseExperimental.GetCacheServerPort())) { if (GUILayout.Button(m_CacheCannotConnectButtonContent, GUILayout.Width(k_ConnectionButtonWidth), GUILayout.Height(k_ConnectionButtonHeight))) { OpenProjectSettings(); } } // Give the option to 'reconnect' as the user may have changed the IP or Port within Project Preferences. else { if (GUILayout.Button(m_CacheCanReconnectButtonContent, GUILayout.Width(k_ConnectionButtonWidth), GUILayout.Height(k_ConnectionButtonHeight))) { AssetDatabaseExperimental.RefreshSettings(); } } } else { if (GUILayout.Button(m_CacheDisabledButtonContent, GUILayout.Width(k_ConnectionButtonWidth), GUILayout.Height(k_ConnectionButtonHeight))) { OpenProjectSettings(); } } } }
static void CacheServerVersion2GUI(bool allowCacheServerChanges, string overrideAddress) { GUILayout.Space(5); bool changeStateBeforeControls = GUI.changed; s_CacheServer2Mode = (CacheServer2Mode)EditorGUILayout.EnumPopup(Properties.cacheServerDefaultMode, s_CacheServer2Mode); s_CacheServer2IPAddress = EditorGUILayout.TextField(Properties.cacheServerIPLabel, s_CacheServer2IPAddress); if (GUI.changed != changeStateBeforeControls) { s_ConnectionState = ConnectionState.Unknown; } GUILayout.Space(5); using (new EditorGUI.DisabledScope(AssetDatabase.IsV1Enabled())) { if (GUILayout.Button("Check Connection", GUILayout.Width(150))) { var address = s_CacheServer2IPAddress.Split(':'); var ip = address[0]; UInt16 port = 0; if (address.Length == 2) { port = Convert.ToUInt16(address[1]); } if (AssetDatabaseExperimental.CanConnectToCacheServer(ip, port)) { s_ConnectionState = ConnectionState.Success; } else { s_ConnectionState = ConnectionState.Failure; } } } GUILayout.Space(-25); var s = AssetDatabase.IsV2Enabled() ? s_ConnectionState : ConnectionState.Unknown; switch (s) { case ConnectionState.Success: EditorGUILayout.HelpBox("Connection successful.", MessageType.Info, false); break; case ConnectionState.Failure: EditorGUILayout.HelpBox("Connection failed.", MessageType.Warning, false); break; case ConnectionState.Unknown: GUILayout.Space(44); break; } }
private void DoCacheServerSettings() { GUILayout.Space(10); GUILayout.Label(Content.cacheServer, EditorStyles.boldLabel); var overrideAddress = CacheServerPreferences.GetCommandLineRemoteAddressOverride(); if (overrideAddress != null) { EditorGUILayout.HelpBox("Cache Server remote address forced via command line argument. To use the cache server address specified here please restart Unity without the -CacheServerIPAddress command line argument.", MessageType.Info, true); } int index = Mathf.Clamp((int)EditorSettings.cacheServerMode, 0, cacheServerModePopupList.Length - 1); CreatePopupMenu(Content.mode.text, cacheServerModePopupList, index, SetCacheServerMode); if (index != (int)CacheServerMode.Disabled) { bool isCacheServerEnabled = true; if (index == (int)CacheServerMode.AsPreferences) { if (CacheServerPreferences.IsCacheServerV2Enabled) { var cacheServerIP = CacheServerPreferences.CachesServerV2Address; cacheServerIP = string.IsNullOrEmpty(cacheServerIP) ? "Not set in preferences" : cacheServerIP; EditorGUILayout.HelpBox(cacheServerIP, MessageType.None, false); } else { isCacheServerEnabled = false; EditorGUILayout.HelpBox("Disabled", MessageType.None, false); } } if (isCacheServerEnabled) { var oldEndpoint = EditorSettings.cacheServerEndpoint; var newEndpoint = EditorGUILayout.TextField(Content.cacheServerIPLabel, oldEndpoint); if (newEndpoint != oldEndpoint) { EditorSettings.cacheServerEndpoint = newEndpoint; } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Check Connection", GUILayout.Width(150))) { if (AssetDatabase.IsV2Enabled()) { var address = EditorSettings.cacheServerEndpoint.Split(':'); var ip = address[0]; UInt16 port = 0; // If 0, will use the default set port if (address.Length == 2) { port = Convert.ToUInt16(address[1]); } if (AssetDatabaseExperimental.CanConnectToCacheServer(ip, port)) { m_CacheServerConnectionState = CacheServerConnectionState.Success; } else { m_CacheServerConnectionState = CacheServerConnectionState.Failure; } } else { if (InternalEditorUtility.CanConnectToCacheServer()) { m_CacheServerConnectionState = CacheServerConnectionState.Success; } else { m_CacheServerConnectionState = CacheServerConnectionState.Failure; } } } GUILayout.Space(25); switch (m_CacheServerConnectionState) { case CacheServerConnectionState.Success: EditorGUILayout.HelpBox("Connection successful.", MessageType.Info, true); break; case CacheServerConnectionState.Failure: EditorGUILayout.HelpBox("Connection failed.", MessageType.Warning, true); break; case CacheServerConnectionState.Unknown: GUILayout.Space(44); break; } EditorGUILayout.EndHorizontal(); var old = EditorSettings.cacheServerNamespacePrefix; var newvalue = EditorGUILayout.TextField(Content.cacheServerNamespacePrefixLabel, old); if (newvalue != old) { EditorSettings.cacheServerNamespacePrefix = newvalue; } EditorGUI.BeginChangeCheck(); bool enableDownload = EditorSettings.cacheServerEnableDownload; enableDownload = EditorGUILayout.Toggle(Content.cacheServerEnableDownloadLabel, enableDownload); if (EditorGUI.EndChangeCheck()) { EditorSettings.cacheServerEnableDownload = enableDownload; } EditorGUI.BeginChangeCheck(); bool enableUpload = EditorSettings.cacheServerEnableUpload; enableUpload = EditorGUILayout.Toggle(Content.cacheServerEnableUploadLabel, enableUpload); if (EditorGUI.EndChangeCheck()) { EditorSettings.cacheServerEnableUpload = enableUpload; } bool enableAuth = EditorSettings.cacheServerEnableAuth; using (new EditorGUI.DisabledScope(enableAuth)) { EditorGUI.BeginChangeCheck(); bool enableTls = EditorSettings.cacheServerEnableTls; enableTls = EditorGUILayout.Toggle(Content.cacheServerEnableTlsLabel, enableTls); if (EditorGUI.EndChangeCheck()) { EditorSettings.cacheServerEnableTls = enableTls; } } EditorGUI.BeginChangeCheck(); enableAuth = EditorGUILayout.Toggle(Content.cacheServerEnableAuthLabel, enableAuth); if (EditorGUI.EndChangeCheck()) { EditorSettings.cacheServerEnableAuth = enableAuth; if (enableAuth) { EditorSettings.cacheServerEnableTls = true; } } EditorGUI.indentLevel++; using (new EditorGUI.DisabledScope(!enableAuth)) { int authModeIndex = Convert.ToInt32(EditorUserSettings.GetConfigValue("cacheServerAuthMode")); CreatePopupMenu(Content.mode.text, cacheServerAuthMode, authModeIndex, SetCacheServerAuthMode); string oldUserVal = EditorUserSettings.GetConfigValue("cacheServerAuthUser"); var newUserVal = EditorGUILayout.TextField(Content.cacheServerAuthUserLabel, oldUserVal); if (newUserVal != oldUserVal) { EditorUserSettings.SetConfigValue("cacheServerAuthUser", newUserVal); } var oldPasswordVal = EditorUserSettings.GetConfigValue("cacheServerAuthPassword"); var newPasswordVal = EditorGUILayout.PasswordField(Content.cacheServerAuthPasswordLabel, oldPasswordVal); if (newPasswordVal != oldPasswordVal) { EditorUserSettings.SetPrivateConfigValue("cacheServerAuthPassword", newPasswordVal); } } EditorGUI.indentLevel--; } } }