文档

Unity Engine

Unity Engine

BeginProperty

Starts a property wrapper for a GUI control that edits a serialized material setting, using automatic layout.
阅读时间3 分钟最后更新于 21 天前

Definition

  • Type: Method
  • Namespace: UnityEditor
  • Assembly: UnityEditor.CoreModule

BeginProperty(SerializedProperty)

Starts a property wrapper for a GUI control that edits a serialized material setting, using automatic layout.
public static void BeginProperty(SerializedProperty property)

Parameters

The serialized property for the material setting that the GUI control edits.

Remarks

MaterialEditor has methods that draw specific material properties, such as MaterialEditor.ShaderProperty and MaterialEditor.TextureProperty. If you draw a property with another GUI control instead, such as EditorGUI.Toggle, wrap the control in a property wrapper to get the standard behavior. The wrapper shows material variant overrides in bold, adds the Apply and Revert options to the context menu, disables the control for locked properties, and handles editing multiple different values. End the wrapper with MaterialEditor.EndProperty. Use this overload when you draw a control for Material.renderQueue, Material.doubleSidedGI, Material.enableInstancing, or Material.globalIlluminationFlags, and pass the matching SerializedProperty. This overload doesn't take a rectangle, so the Unity Editor uses GUILayoutUtility.GetLastRect at the end of the wrapper to find the position of the control.

BeginProperty(Rect, SerializedProperty)

Starts a property wrapper for a GUI control that edits a serialized material setting, at a specified position.
public static void BeginProperty(Rect rect, SerializedProperty property)

Parameters

rect

The position and size of the GUI control, including any label.

The serialized property for the material setting that the GUI control edits.

Remarks

MaterialEditor has methods that draw specific material properties, such as MaterialEditor.ShaderProperty and MaterialEditor.TextureProperty. If you draw a property with another GUI control instead, such as EditorGUI.Toggle, wrap the control in a property wrapper to get the standard behavior. The wrapper shows material variant overrides in bold, adds the Apply and Revert options to the context menu, disables the control for locked properties, and handles editing multiple different values. End the wrapper with MaterialEditor.EndProperty. Use this overload when you draw a control for Material.renderQueue, Material.doubleSidedGI, Material.enableInstancing, or Material.globalIlluminationFlags, and pass the matching SerializedProperty.

BeginProperty(MaterialProperty)

Starts a property wrapper for a GUI control that edits a material property, using automatic layout.
public static void BeginProperty(MaterialProperty property)

Parameters

The material property that the GUI control edits.

Remarks

MaterialEditor has methods that draw specific material properties, such as MaterialEditor.ShaderProperty and MaterialEditor.TextureProperty. If you draw a property with another GUI control instead, such as EditorGUI.Toggle, wrap the control in a property wrapper to get the standard behavior. The wrapper shows material variant overrides in bold, adds the Apply and Revert options to the context menu, disables the control for locked properties, and handles editing multiple different values. End the wrapper with MaterialEditor.EndProperty. This overload doesn't take a rectangle, so the Unity Editor uses GUILayoutUtility.GetLastRect at the end of the wrapper to find the position of the control.

BeginProperty(Rect, MaterialProperty)

Starts a property wrapper for a GUI control that edits a material property, at a specified position.
public static void BeginProperty(Rect rect, MaterialProperty property)

Parameters

rect

The position and size of the GUI control, including any label.

The material property that the GUI control edits.

Remarks

MaterialEditor has methods that draw specific material properties, such as MaterialEditor.ShaderProperty and MaterialEditor.TextureProperty. If you draw a property with another GUI control instead, such as EditorGUI.Toggle, wrap the control in a property wrapper to get the standard behavior. The wrapper shows material variant overrides in bold, adds the Apply and Revert options to the context menu, disables the control for locked properties, and handles editing multiple different values. End the wrapper with MaterialEditor.EndProperty.