コード例 #1
0
 /// <summary>
 /// Prefix label to show above control.
 /// </summary>
 /// <param name="text">Text for label.</param>
 /// <param name="style">Style for prefix label.</param>
 public static void AbovePrefixLabel(string text, GUIStyle style)
 {
     using (var labelContent = ControlContent.Basic(text)) {
         Rect position = GUILayoutUtility.GetRect(labelContent, style);
         EditorGUI.HandlePrefixLabel(position, position, labelContent, 0, style);
     }
 }
コード例 #2
0
        public static void TrailingTip(string tipText)
        {
            if (string.IsNullOrEmpty(tipText))
            {
                return;
            }

            using (var labelContent = ControlContent.Basic(tipText)) {
                Rect position = GUILayoutUtility.GetRect(labelContent, ExtraEditorStyles.Instance.TrailingTip);
                position.y -= 2;

                EditorGUI.LabelField(position, labelContent, ExtraEditorStyles.Instance.TrailingTip);
            }
        }
コード例 #3
0
        public static bool IconButton(Rect position, bool visible, Texture2D iconNormal, Texture2D iconActive, GUIStyle style)
        {
            int  controlID = GUIUtility.GetControlID(s_IconButtonHint, FocusType.Passive);
            bool result    = false;

            position.height += 1;

            switch (Event.current.GetTypeForControl(controlID))
            {
            case EventType.MouseDown:
                // Do not allow button to be pressed using right mouse button since
                // context menu should be shown instead!
                if (GUI.enabled && Event.current.button != 1 && position.Contains(Event.current.mousePosition))
                {
                    GUIUtility.hotControl      = controlID;
                    GUIUtility.keyboardControl = 0;
                    Event.current.Use();
                }
                break;

            case EventType.MouseDrag:
                if (GUIUtility.hotControl == controlID)
                {
                    Event.current.Use();
                }
                break;

            case EventType.MouseUp:
                if (GUIUtility.hotControl == controlID)
                {
                    GUIUtility.hotControl = 0;
                    result = position.Contains(Event.current.mousePosition);
                    Event.current.Use();
                }
                break;

            case EventType.Repaint:
                if (visible)
                {
                    bool isActive = GUIUtility.hotControl == controlID && position.Contains(Event.current.mousePosition);
                    using (var tempContent = ControlContent.Basic(isActive ? iconActive : iconNormal)) {
                        position.height -= 1;
                        style.Draw(position, tempContent, isActive, isActive, false, false);
                    }
                }
                break;
            }

            return(result);
        }
コード例 #4
0
 public static void ToggleLeft(SerializedProperty prop, string label)
 {
     using (var labelContent = ControlContent.Basic(label)) {
         ToggleLeft(prop, labelContent);
     }
 }