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--;
}
}
}