Version: 2022.2
LanguageEnglish
  • C#

EditorGUI.PrefixLabel

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public static Rect PrefixLabel(Rect totalPosition, GUIContent label);

Declaration

public static Rect PrefixLabel(Rect totalPosition, GUIContent label, GUIStyle style);

Declaration

public static Rect PrefixLabel(Rect totalPosition, int id, GUIContent label);

Declaration

public static Rect PrefixLabel(Rect totalPosition, int id, GUIContent label, GUIStyle style);

Parameters

totalPosition Rectangle on the screen to use in total for both the label and the control.
id The unique ID of the control. If none specified, the ID of the following control is used.
label Label to show in front of the control.
style Style to use for the label.

Returns

Rect Rectangle on the screen to use just for the control itself.

Description

Makes a label in front of some control.


Prefix Label in an Editor Window.

Note that most editor controls already have built-in optional labels that can be specified as one of the parameters. PrefixLabel can be used when there is no such built-in label available, or when you're creating your own editor control from scratch.

PrefixLabel takes a rect that's the rect for the entire control, including the label, and returns a rect that's for just the control itself, without the label.

PrefixLabel also ensures that when the label is clicked, the linked control will get keyboard focus (if the control supports keyboard focus). The ID of the linked control can optionally be specified, or if no ID is given, the label is automatically linked to the following control coming after it.

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961