示例#1
0
        private Rect GetFrame(int size)
        {
            Rect fieldArea = EditorGUILayout.GetControlRect(false, size);

            fieldArea.width = size;
            fieldArea.x    += LDtkEditorGUIUtility.LabelWidth(fieldArea.width) + 2;
            return(fieldArea);
        }
示例#2
0
        protected bool DrawButtonToLeftOfField(Rect controlRect, GUIContent content, int indentLevel = 0)
        {
            float labelWidth = LDtkEditorGUIUtility.LabelWidth(controlRect.width);

            Rect buttonRect = new Rect(controlRect)
            {
                x = controlRect.x + labelWidth - controlRect.height * (indentLevel + 1),

                width  = controlRect.height,
                height = controlRect.height,
            };
            bool isPressed = GUI.Button(buttonRect, GUIContent.none);

            if (content == null || content.image == null)
            {
                return(isPressed);
            }

            Rect imageArea = new Rect(buttonRect)
            {
                width  = buttonRect.width - 2,
                height = buttonRect.height - 2,
                center = buttonRect.center
            };

            GUIContent tooltipContent = new GUIContent()
            {
                tooltip = content.tooltip
            };


            GUI.Label(imageArea, tooltipContent);
            GUI.DrawTexture(imageArea, content.image);

            return(isPressed);
        }
示例#3
0
        public static Vector2 GetFieldIconPosition(Rect controlRect)
        {
            float labelWidth = LDtkEditorGUIUtility.LabelWidth(controlRect.width);

            return(new Vector2(controlRect.xMin + labelWidth, controlRect.yMin + controlRect.height / 2));
        }