Example #1
0
 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();
             }
         }
     }
 }
Example #2
0
        public override void OnGUI(Rect rect)
        {
            var exit = false;

            GUILayout.BeginArea(rect, m_WindowStyle);
            GUILayout.BeginHorizontal();
            GUILayout.Label(m_WindowTitleContent, EditorStyles.boldLabel);
            if (GUILayout.Button(GUIContent.none, m_CacheServerOverflowMenuButtonStyle))
            {
                var menu = new GenericMenu();
                menu.AddItem(m_WindowOverflowMenuPreferencesButtonContent, false, () =>
                {
                    OpenPreferences();
                });
                menu.AddItem(m_WindowOverflowMenuProjectSettingsButtonContent, false, () =>
                {
                    OpenProjectSettings();
                });
                menu.ShowAsContext();
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(k_Header_footer_vertical_padding);

            GUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(k_StatusText, ConnectionStatusText());
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(k_EndpointText, AssetDatabaseExperimental.GetCacheServerAddress());
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(k_NamespaceText, AssetDatabaseExperimental.GetCacheServerNamespacePrefix());
            GUILayout.EndHorizontal();

            GUILayout.Space(k_Header_footer_vertical_padding);

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            OnGUIFooter();
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.EndArea();

            exit |= Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape;

            if (exit)
            {
                editorWindow.Close();
                GUIUtility.ExitGUI();
            }
        }
        public override void OnGUI(Rect rect)
        {
            var exit = false;

            GUILayout.BeginArea(rect, m_WindowStyle);
            if (AssetDatabaseExperimental.IsCacheServerEnabled())
            {
                var iconPosition = new Rect();
                iconPosition.x      = rect.width - m_RefreshIcon.image.width - m_WindowStyle.padding.right;
                iconPosition.y      = m_WindowStyle.padding.top;
                iconPosition.width  = m_RefreshIcon.image.width;
                iconPosition.height = m_RefreshIcon.image.height;
                GUIStyle helpIconStyle = EditorStyles.iconButton;
                if (GUI.Button(iconPosition, m_RefreshIcon, helpIconStyle))
                {
                    AssetDatabaseExperimental.RefreshSettings();
                }

                GUILayout.BeginHorizontal();
                var style = new GUIStyle();
                style.fontStyle        = FontStyle.Bold;
                style.normal.textColor = EditorStyles.boldLabel.normal.textColor;
                if (!AssetDatabaseExperimental.IsConnectedToCacheServer())
                {
                    style.normal.textColor = new Color(0.97f, 0.32f, 0.31f);
                }
                EditorGUILayout.LabelField(AssetDatabaseExperimental.GetCacheServerAddress(), style);
                GUILayout.EndHorizontal();
            }

            GUILayout.BeginHorizontal();
            var statusTextStyle = new GUIStyle()
            {
                normal = { textColor = Color.grey }
            };

            EditorGUILayout.LabelField(ConnectionStatusText(), statusTextStyle);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button(m_OpenProjectSettings, "ControlLabel"))
            {
                OpenProjectSettings();
            }
            GUILayout.EndHorizontal();
            GUILayout.EndArea();

            exit |= Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape;
            if (exit)
            {
                editorWindow.Close();
                GUIUtility.ExitGUI();
            }
        }
Example #4
0
        public override void OnGUI(Rect rect)
        {
            var exit = false;

            var labelStyle = new GUIStyle(GUI.skin.label)
            {
                alignment = TextAnchor.MiddleRight
            };

            GUILayout.BeginArea(rect, m_WindowStyle);

            GUILayout.BeginHorizontal();
            GUILayout.Label(m_CacheServerTitleContent, EditorStyles.boldLabel);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label(m_CacheServerStatusTextContent);
            if (!AssetDatabaseExperimental.IsCacheServerEnabled())
            {
                GUILayout.Label(m_CacheServerStatusDisabledTextContent, labelStyle);
            }
            else if (!AssetDatabaseExperimental.IsConnectedToCacheServer())
            {
                GUILayout.Label(m_CacheServerStatusDisconnectedTextContent, labelStyle);
            }
            else
            {
                GUILayout.Label(m_CacheServerStatusConnectedTextContent, labelStyle);
            }
            GUILayout.EndHorizontal();

            using (new EditorGUI.DisabledScope(!AssetDatabaseExperimental.IsCacheServerEnabled()))
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label(m_CacheServerEndpointTextContent);
                GUILayout.Label(AssetDatabaseExperimental.GetCacheServerAddress(), labelStyle);
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label(m_CacheServerNamespaceTextContent);
                GUILayout.Label(AssetDatabaseExperimental.GetCacheServerNamespacePrefix(), labelStyle);
                GUILayout.EndHorizontal();

                GUILayout.Space(10);

                // GUILayout.BeginHorizontal();
                // if (GUILayout.Button(m_CacheServerDisableButtonContent))
                // {
                //     // TODO - Disable cache server
                // }
                // GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                if (GUILayout.Button(m_CacheServerReconnectButtonContent))
                {
                    AssetDatabaseExperimental.RefreshSettings();
                }
                GUILayout.EndHorizontal();
            }

            GUILayout.EndArea();

            exit |= Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape;

            if (exit)
            {
                editorWindow.Close();
                GUIUtility.ExitGUI();
            }
        }