docs.unity3d.com
    显示 / 隐藏目录

    Class EditorGUIUtils

    Inheritance
    Object
    EditorGUIUtils
    Namespace: Unity.MARS
    Syntax
    public static class EditorGUIUtils

    Methods

    Drag2D(Vector2, Rect)

    Declaration
    public static Vector2 Drag2D(Vector2 scrollPosition, Rect position)
    Parameters
    Type Name Description
    Vector2 scrollPosition
    Rect position
    Returns
    Type Description
    Vector2

    DrawBoxSplitter()

    Draw a splitter using the style of a 1pixel box.

    Declaration
    public static void DrawBoxSplitter()

    DrawCheckboxFillerRect()

    Reserve a checkbox-sized rectangle

    Declaration
    public static Rect DrawCheckboxFillerRect()
    Returns
    Type Description
    Rect

    The reserved rectangle

    DrawCheckboxFillerRect(ref Rect)

    Reserve a checkbox-sized rectangle, given a max bounding region

    Declaration
    public static Rect DrawCheckboxFillerRect(ref Rect source)
    Parameters
    Type Name Description
    Rect source

    The source rect to fit this checkbox within

    Returns
    Type Description
    Rect

    The reserved rectangle

    DrawDefaultInspectorWithColor(ComponentInspector, Nullable<Color>)

    Draw component inspector's default inspector but with values in an override color

    Declaration
    public static void DrawDefaultInspectorWithColor(this ComponentInspector componentInspector, Color? overrideColor = null)
    Parameters
    Type Name Description
    ComponentInspector componentInspector

    The inspector to draw

    Nullable<Color> overrideColor

    The color to use, or null for no override

    DrawDictionary<TKey>(Dictionary<TKey, Single>, String, String, GUILayoutOption, GUILayoutOption, String)

    Draw the entries in a dictionary with floating-point values in two columns

    Declaration
    public static void DrawDictionary<TKey>(Dictionary<TKey, float> dictionary, string keyLabel, string valueLabel, GUILayoutOption keyWidth, GUILayoutOption valueWidth, string floatFormat = "F3")
    Parameters
    Type Name Description
    Dictionary<TKey, Single> dictionary

    The dictionary of values to draw

    String keyLabel

    The text to display at the top of the keys column

    String valueLabel

    The text to display at the top of the values column

    GUILayoutOption keyWidth

    Layout options to be applied to the keys column

    GUILayoutOption valueWidth

    Layout options to be applied to the values column

    String floatFormat

    A format string specifying how to print floating-point values

    Type Parameters
    Name Description
    TKey

    DrawDictionary<TKey, TValue>(Dictionary<TKey, TValue>, String, String, GUILayoutOption, GUILayoutOption, Func<TValue, String>)

    Draw the values in a dictionary in two columns

    Declaration
    public static void DrawDictionary<TKey, TValue>(Dictionary<TKey, TValue> dictionary, string keyLabel, string valueLabel, GUILayoutOption keyWidth = null, GUILayoutOption valueWidth = null, Func<TValue, string> customValueToString = null)
    Parameters
    Type Name Description
    Dictionary<TKey, TValue> dictionary

    The dictionary of values to draw

    String keyLabel

    The text to display at the top of the keys column

    String valueLabel

    The text to display at the top of the values column

    GUILayoutOption keyWidth

    Layout options to be applied to the keys column

    GUILayoutOption valueWidth

    Layout options to be applied to the values column

    Func<TValue, String> customValueToString

    (optional) A function that turns the Value entries into strings in a non-standard way

    Type Parameters
    Name Description
    TKey
    TValue

    DrawDictionaryWithHeader<TKey, TValue>(Dictionary<TKey, TValue>, String, String, String, GUILayoutOption, GUILayoutOption, Func<TValue, String>)

    Draw the values in a dictionary in two columns

    Declaration
    public static void DrawDictionaryWithHeader<TKey, TValue>(Dictionary<TKey, TValue> dictionary, string title, string keyLabel, string valueLabel, GUILayoutOption keyWidth = null, GUILayoutOption valueWidth = null, Func<TValue, string> customValueToString = null)
    Parameters
    Type Name Description
    Dictionary<TKey, TValue> dictionary

    The dictionary of values to draw

    String title

    The text to display in the header for the dictionary

    String keyLabel

    The text to display at the top of the keys column

    String valueLabel

    The text to display at the top of the values column

    GUILayoutOption keyWidth

    Layout options to be applied to the keys column

    GUILayoutOption valueWidth

    Layout options to be applied to the values column

    Func<TValue, String> customValueToString
    Type Parameters
    Name Description
    TKey
    TValue

    DrawFoldoutUI(Boolean, Boolean, String, GUIStyle, GUIStyle, Action, Action<Boolean>, Action, Func<GenericMenu>, Func<GenericMenu>)

    Draw a component stack style header with an expandable GUI method

    Declaration
    public static bool DrawFoldoutUI(bool expanded, bool showToggle, string title, GUIStyle toggleStyle, GUIStyle labelStyle, Action drawFoldoutUI, Action<bool> onExpandedChanged, Action helpButton, Func<GenericMenu> settingsButtonFn, Func<GenericMenu> menuFn)
    Parameters
    Type Name Description
    Boolean expanded

    Expanded state of the foldout

    Boolean showToggle

    Is the toggle for expanding the panel visible.

    String title

    The title to display on the foldout header

    GUIStyle toggleStyle

    GUI Style to be applied to the toggle button in the header

    GUIStyle labelStyle

    GUI Style to be applied to the label in the header

    Action drawFoldoutUI

    Function to draw UI when expanded. Function returns the rect of the panel.

    Action<Boolean> onExpandedChanged

    Action called when expanded state changes

    Action helpButton

    Action called when help button is pressed. If Null no help button is drawn.

    Func<GenericMenu> settingsButtonFn

    GenericMenu method to define the popup options menu. If no function is provided or function returns null no button is drawn.

    Func<GenericMenu> menuFn

    GenericMenu method to define the header's menu. If no menuFn is provided other menuFn returns null, a menu icon won't be drawn

    Returns
    Type Description
    Boolean

    Returns true if the foldout is expanded and enabled

    DrawHeader(String, SerializedProperty, SerializedProperty, Action, Action, Action, Action, Boolean, Boolean)

    Draw a component stack style header

    Declaration
    public static bool DrawHeader(string title, SerializedProperty propertyGroup, SerializedProperty activeField, Action resetAction, Action removeAction, Action copyAction, Action pasteAction, bool canPaste, bool drawFoldout)
    Parameters
    Type Name Description
    String title

    Label to display on the header

    SerializedProperty propertyGroup

    Property representing the component

    SerializedProperty activeField

    Property representing if the component is active

    Action resetAction

    Action to reset the component from the header context menu

    Action removeAction

    Action to remove the component from the header context menu

    Action copyAction

    Action to copy the component from the header context menu

    Action pasteAction

    Action to paste the component from the header context menu

    Boolean canPaste

    Can the copied component be pasted

    Boolean drawFoldout

    Draw the foldout drop down and do foldout behavior

    Returns
    Type Description
    Boolean

    Returns true if the header is expanded

    DrawOverrideCheckbox(Rect, SerializedPropertyData)

    Draw a component stack style checkbox, showing the value of property

    Declaration
    public static void DrawOverrideCheckbox(Rect rect, SerializedPropertyData property)
    Parameters
    Type Name Description
    Rect rect

    Rect in which to draw the checkbox

    SerializedPropertyData property

    Property to reflect in the checkbox (must be a Boolean)

    DrawOverrideCheckbox(Rect, SerializedProperty)

    Draw a component stack style checkbox, showing the value of property

    Declaration
    public static void DrawOverrideCheckbox(Rect rect, SerializedProperty property)
    Parameters
    Type Name Description
    Rect rect

    Rect in which to draw the checkbox

    SerializedProperty property

    Property to reflect in the checkbox (must be a Boolean)

    DrawSplitter()

    Draw a thin line, for use between component stack headers

    Declaration
    public static void DrawSplitter()

    FindSerializedPropertyData(SerializedObject, String)

    Declaration
    public static SerializedPropertyData FindSerializedPropertyData(this SerializedObject serializedObject, string propertyName)
    Parameters
    Type Name Description
    SerializedObject serializedObject
    String propertyName
    Returns
    Type Description
    SerializedPropertyData

    FindSerializedPropertyData(SerializedProperty)

    Declaration
    public static SerializedPropertyData FindSerializedPropertyData(SerializedProperty property)
    Parameters
    Type Name Description
    SerializedProperty property
    Returns
    Type Description
    SerializedPropertyData

    FormatAngleDegreesString(Single)

    Formats an angle value as a string with rounding and a degree symbol

    Declaration
    public static string FormatAngleDegreesString(float angle)
    Parameters
    Type Name Description
    Single angle

    The angle value

    Returns
    Type Description
    String

    GetContent(String)

    Get a GUIContent from input string, with text and tooltip separated by a | pipe character

    Declaration
    public static GUIContent GetContent(string textAndTooltip)
    Parameters
    Type Name Description
    String textAndTooltip

    Combined text and tooltip string, separated by a | pipe character

    Returns
    Type Description
    GUIContent

    The resulting GUIContent

    ImageToggle(Boolean, GUIContent, Texture, Texture, GUIStyle, GUILayoutOption[])

    Recreates the toggle button and functionality with gui button.

    Declaration
    public static bool ImageToggle(bool value, GUIContent guiContent, Texture onImage, Texture offImage, GUIStyle style, params GUILayoutOption[] options)
    Parameters
    Type Name Description
    Boolean value

    Current value of toggle parameter.

    GUIContent guiContent

    GUI content to display on the button.

    Texture onImage

    Texture to display on the button when it is on.

    Texture offImage

    Texture to display on the button when it is off.

    GUIStyle style

    The style to use. If left out, the button style from the current GUISkin is used.

    GUILayoutOption[] options

    An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the style.<br> See Also: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

    Returns
    Type Description
    Boolean

    The selected state of the toggle.

    MouseLabel(String)

    Draw a label in a box next to the mouse cursor

    Declaration
    public static void MouseLabel(string text)
    Parameters
    Type Name Description
    String text

    The text to display in the label

    PropertyField(SerializedPropertyData, Boolean, Boolean)

    Draw a property field, with no checkbox

    Declaration
    public static void PropertyField(SerializedPropertyData property, bool onlyHideToggle = false, bool showHideInInspector = true)
    Parameters
    Type Name Description
    SerializedPropertyData property

    The property being drawn

    Boolean onlyHideToggle
    Boolean showHideInInspector

    Force this property to draw despite a HideInInspector attribute

    PropertyField(SerializedPropertyData, SerializedPropertyData, Boolean, Boolean, Nullable<Color>)

    Draw a property field, with checkbox if appropriate

    Declaration
    public static void PropertyField(SerializedPropertyData toggleProperty, SerializedPropertyData property, bool onlyHideToggle = false, bool showHideInInspector = true, Color? overrideColor = null)
    Parameters
    Type Name Description
    SerializedPropertyData toggleProperty

    Property representing the checkbox value

    SerializedPropertyData property

    The property being drawn

    Boolean onlyHideToggle
    Boolean showHideInInspector

    Force this property to draw despite a HideInInspector attribute

    Nullable<Color> overrideColor

    The color to use, or null for no override

    PropertyField(SerializedPropertyData, SerializedPropertyData, String, Boolean, Boolean)

    Draw a property field, with checkbox if appropriate

    Declaration
    public static void PropertyField(SerializedPropertyData toggleProperty, SerializedPropertyData property, string customLabel, bool onlyHideToggle = false, bool showHideInInspector = true)
    Parameters
    Type Name Description
    SerializedPropertyData toggleProperty

    Property representing the checkbox value

    SerializedPropertyData property

    The property being drawn

    String customLabel

    The custom label to use for this property

    Boolean onlyHideToggle
    Boolean showHideInInspector

    Force this property to draw despite a HideInInspector attribute

    PropertyField(SerializedPropertyData, SerializedPropertyData, GUIContent, Boolean, Boolean)

    Draw a property field, with checkbox if appropriate

    Declaration
    public static void PropertyField(SerializedPropertyData toggleProperty, SerializedPropertyData property, GUIContent title, bool onlyHideToggle = false, bool showHideInInspector = true)
    Parameters
    Type Name Description
    SerializedPropertyData toggleProperty

    Property representing the checkbox value

    SerializedPropertyData property

    The property being drawn

    GUIContent title

    The label to display for this property

    Boolean onlyHideToggle
    Boolean showHideInInspector

    Force this property to draw despite a HideInInspector attribute

    PropertyField(SerializedPropertyData, GUIContent, Boolean, Boolean)

    Draw a property field, with no checkbox

    Declaration
    public static void PropertyField(SerializedPropertyData property, GUIContent title, bool onlyHideToggle = false, bool showHideInInspector = true)
    Parameters
    Type Name Description
    SerializedPropertyData property

    The property being drawn

    GUIContent title

    The label to display for this property

    Boolean onlyHideToggle
    Boolean showHideInInspector

    Force this property to draw despite a HideInInspector attribute

    PropertyFieldInRect(Rect, SerializedPropertyData, SerializedPropertyData, Boolean, Boolean)

    Draw a property field within a specified region, with checkbox if appropriate

    Declaration
    public static void PropertyFieldInRect(Rect position, SerializedPropertyData toggleProperty, SerializedPropertyData property, bool onlyHideToggle = false, bool showHideInInspector = true)
    Parameters
    Type Name Description
    Rect position

    Where these properties should be drawn

    SerializedPropertyData toggleProperty

    Property representing the checkbox value

    SerializedPropertyData property

    The property being drawn

    Boolean onlyHideToggle
    Boolean showHideInInspector

    Force this property to draw despite a HideInInspector attribute

    PropertyFieldInRect(Rect, SerializedPropertyData, SerializedPropertyData, GUIContent, Boolean, Boolean)

    Draw a property field within a specified region, with checkbox if appropriate

    Declaration
    public static void PropertyFieldInRect(Rect position, SerializedPropertyData toggleProperty, SerializedPropertyData property, GUIContent title, bool onlyHideToggle = false, bool showHideInInspector = true)
    Parameters
    Type Name Description
    Rect position

    Where these properties should be drawn

    SerializedPropertyData toggleProperty

    Property representing the checkbox value

    SerializedPropertyData property

    The property being drawn

    GUIContent title

    The label to display for this property

    Boolean onlyHideToggle
    Boolean showHideInInspector

    Force this property to draw despite a HideInInspector attribute

    SetLayerLockState(Int32, Boolean)

    Set the Unity layer's visibility

    Declaration
    public static void SetLayerLockState(int layer, bool newLockState)
    Parameters
    Type Name Description
    Int32 layer

    Layer to modify

    Boolean newLockState

    Target lock state of layer

    SetLayerVisibleState(Int32, Boolean)

    Set the Unity layer's visibility

    Declaration
    public static void SetLayerVisibleState(int layer, bool newVisibleState)
    Parameters
    Type Name Description
    Int32 layer

    Layer to modify

    Boolean newVisibleState

    Target view state of layer

    Warning(String)

    Draw a warning message box

    Declaration
    public static void Warning(string warning)
    Parameters
    Type Name Description
    String warning

    The text to display in the warning

    返回到顶部
    Copyright © 2023 Unity Technologies — 商标和使用条款
    • 法律条款
    • 隐私政策
    • Cookie
    • 不要出售或分享我的个人信息
    • Your Privacy Choices (Cookie Settings)