Exemple #1
0
        public override void OnGUI(Rect rect)
        {
            var exit = false;

            GUILayout.BeginArea(rect, m_WindowStyle);
            // Cache server connection url
            if (AssetDatabase.IsCacheServerEnabled())
            {
                var iconPosition = new Rect();
                iconPosition.x      = rect.width - (m_RefreshIcon.image.width / (Screen.dpi > 160 ? 2 : 1)) - 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))
                {
                    AssetDatabase.RefreshSettings();
                }

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

                if (GUILayout.Button(AssetDatabase.GetCacheServerAddress(), style))
                {
                    var url = $"http://{AssetDatabase.GetCacheServerAddress()}:{AssetDatabase.GetCacheServerPort()}";
                    Application.OpenURL(url);
                }
                GUILayout.EndHorizontal();
            }

            // Connection status text label
            GUILayout.BeginHorizontal();
            var statusTextStyle = new GUIStyle()
            {
                normal    = { textColor = Color.grey },
                fontStyle = FontStyle.Italic
            };

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

            // Divider line
            var lineRect = EditorGUILayout.GetControlRect(GUILayout.Height(1));

            lineRect.x     -= 6;
            lineRect.width += 12;
            EditorGUI.DrawRect(lineRect, new Color(0.387f, 0.387f, 0.387f));

            // Open project settings button/label
            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();
            }
        }