UnityEditor.CacheServerPreferences.WritePreferences C# (CSharp) Method

WritePreferences() public static method

public static WritePreferences ( ) : void
return void
        public static void WritePreferences()
        {
            CacheServerMode @int = (CacheServerMode) EditorPrefs.GetInt("CacheServerMode");
            string str = EditorPrefs.GetString("LocalCacheServerPath");
            bool @bool = EditorPrefs.GetBool("LocalCacheServerCustomPath");
            bool flag2 = false;
            if ((@int != s_CacheServerMode) && (@int == CacheServerMode.Local))
            {
                flag2 = true;
            }
            if (s_EnableCustomPath && (str != s_CachePath))
            {
                flag2 = true;
            }
            if (((s_EnableCustomPath != @bool) && (s_CachePath != LocalCacheServer.GetCacheLocation())) && (s_CachePath != ""))
            {
                flag2 = true;
            }
            if (flag2)
            {
                s_LocalCacheServerUsedSize = -1L;
                string message = (s_CacheServerMode != CacheServerMode.Local) ? "You have disabled the local cache." : "You have changed the location of the local cache storage.";
                message = message + " Do you want to delete the old locally cached data at " + LocalCacheServer.GetCacheLocation() + "?";
                if (EditorUtility.DisplayDialog("Delete old Cache", message, "Delete", "Don't Delete"))
                {
                    LocalCacheServer.Clear();
                    s_LocalCacheServerUsedSize = 0L;
                }
            }
            EditorPrefs.SetString("CacheServerIPAddress", s_CacheServerIPAddress);
            EditorPrefs.SetInt("CacheServerMode", (int) s_CacheServerMode);
            EditorPrefs.SetInt("LocalCacheServerSize", s_LocalCacheServerSize);
            EditorPrefs.SetString("LocalCacheServerPath", s_CachePath);
            EditorPrefs.SetBool("LocalCacheServerCustomPath", s_EnableCustomPath);
            if (IsCollabCacheEnabled())
            {
                EditorPrefs.SetString("CollabCacheIPAddress", s_CollabCacheIPAddress);
                EditorPrefs.SetBool("CollabCacheEnabled", s_CollabCacheEnabled);
            }
            LocalCacheServer.Setup();
        }

Usage Example

 public static void OnGUI()
 {
     GUILayout.Space(10f);
     if (!InternalEditorUtility.HasPro())
     {
         GUILayout.Label(EditorGUIUtility.TempContent("You need to have a Pro license to use the cache server.", EditorGUIUtility.GetHelpIcon(MessageType.Warning)), EditorStyles.helpBox, new GUILayoutOption[0]);
     }
     EditorGUI.BeginDisabledGroup(!InternalEditorUtility.HasPro());
     if (!CacheServerPreferences.s_PrefsLoaded)
     {
         CacheServerPreferences.ReadPreferences();
         CacheServerPreferences.s_PrefsLoaded = true;
     }
     EditorGUI.BeginChangeCheck();
     CacheServerPreferences.s_CacheServerEnabled = EditorGUILayout.Toggle("Use Cache Server", CacheServerPreferences.s_CacheServerEnabled, new GUILayoutOption[0]);
     EditorGUI.BeginDisabledGroup(!CacheServerPreferences.s_CacheServerEnabled);
     CacheServerPreferences.s_CacheServerIPAddress = EditorGUILayout.TextField("IP Address", CacheServerPreferences.s_CacheServerIPAddress, new GUILayoutOption[0]);
     if (GUI.changed)
     {
         CacheServerPreferences.s_ConnectionState = CacheServerPreferences.ConnectionState.Unknown;
     }
     GUILayout.Space(5f);
     if (GUILayout.Button("Check Connection", new GUILayoutOption[]
     {
         GUILayout.Width(150f)
     }))
     {
         if (InternalEditorUtility.CanConnectToCacheServer())
         {
             CacheServerPreferences.s_ConnectionState = CacheServerPreferences.ConnectionState.Success;
         }
         else
         {
             CacheServerPreferences.s_ConnectionState = CacheServerPreferences.ConnectionState.Failure;
         }
     }
     GUILayout.Space(-25f);
     CacheServerPreferences.ConnectionState connectionState = CacheServerPreferences.s_ConnectionState;
     if (connectionState != CacheServerPreferences.ConnectionState.Success)
     {
         if (connectionState == CacheServerPreferences.ConnectionState.Failure)
         {
             EditorGUILayout.HelpBox("Connection failed.", MessageType.Warning, false);
         }
     }
     else
     {
         EditorGUILayout.HelpBox("Connection successful.", MessageType.Info, false);
     }
     EditorGUI.EndDisabledGroup();
     if (EditorGUI.EndChangeCheck())
     {
         CacheServerPreferences.WritePreferences();
         CacheServerPreferences.ReadPreferences();
     }
     EditorGUI.EndDisabledGroup();
 }
All Usage Examples Of UnityEditor.CacheServerPreferences::WritePreferences