private Rect GetFrame(int size) { Rect fieldArea = EditorGUILayout.GetControlRect(false, size); fieldArea.width = size; fieldArea.x += LDtkEditorGUIUtility.LabelWidth(fieldArea.width) + 2; return(fieldArea); }
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); }
public static Vector2 GetFieldIconPosition(Rect controlRect) { float labelWidth = LDtkEditorGUIUtility.LabelWidth(controlRect.width); return(new Vector2(controlRect.xMin + labelWidth, controlRect.yMin + controlRect.height / 2)); }