예제 #1
0
 static void ReadCacheServerPreferences()
 {
     if (s_CacheServerPrefsLoaded)
     {
         return;
     }
     s_CacheServer2IPAddress  = EditorPrefs.GetString(kCacheServerIPAddressKey, s_CacheServer2IPAddress);
     s_CacheServer2Mode       = (CacheServer2Mode)EditorPrefs.GetInt(kCacheServerModeKey, (int)CacheServer2Mode.Disabled);
     s_CacheServerMode        = (CacheServerMode)EditorPrefs.GetInt(kModeKey, (int)(EditorPrefs.GetBool(kDeprecatedEnabledKey) ? CacheServerMode.Remote : CacheServerMode.Disabled));
     s_CachePath              = EditorPrefs.GetString(LocalCacheServer.PathKey);
     s_EnableCustomPath       = EditorPrefs.GetBool(LocalCacheServer.CustomPathKey);
     s_CacheServerPrefsLoaded = true;
 }
        static void CacheServerVersion2GUI(bool allowCacheServerChanges, string overrideAddress)
        {
            GUILayout.Label(Properties.assetPipelineVersion2, EditorStyles.boldLabel);

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