示例#1
0
        static void CacheServerGUI()
        {
            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;
            }

            EditorGUILayout.Space();

            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 (AssetDatabase.CanConnectToCacheServer(ip, port))
                {
                    s_ConnectionState = ConnectionState.Success;
                }
                else
                {
                    s_ConnectionState = ConnectionState.Failure;
                }
            }

            GUILayout.Space(-25);

            switch (s_ConnectionState)
            {
            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;
            }
        }
        static void CacheServerGUI()
        {
            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;
            }

            EditorGUILayout.Space();

            if (GUILayout.Button("Check Connection", GUILayout.Width(150)))
            {
                if (ParseCacheServerAddress(s_CacheServer2IPAddress, out var ip, out var port) && AssetDatabase.CanConnectToCacheServer(ip, port))
                {
                    s_ConnectionState = ConnectionState.Success;
                }
                else
                {
                    s_ConnectionState = ConnectionState.Failure;
                }
            }