EditorGUI.MixedValueScope
Creates a group of controls that can visually represent a mixed value.
Read time 1 minuteLast updated 4 days ago
Definition
- Type: Struct
- Namespace: UnityEditor
- Assembly: UnityEditor
- Implements: IDisposable
public struct EditorGUI.MixedValueScope : IDisposable
Remarks
To configure a group of controls that can show a dash (-) if selected objects have different values, add before the group and set newMixedValue to true.
EditorGUI.MixedValueScopeusing UnityEditor;using UnityEngine;[CanEditMultipleObjects][CustomEditor(typeof(MixedValueComponentTest))]public class MixedValueComponentTestEditor : Editor{ public override void OnInspectorGUI() { SerializedProperty serializedPropertyMyInt = serializedObject.FindProperty("MyInt"); using (new EditorGUI.MixedValueScope(serializedPropertyMyInt.hasMultipleDifferentValues)) { EditorGUI.BeginChangeCheck(); int newValue = EditorGUILayout.IntField("My Int", serializedPropertyMyInt.intValue); if (EditorGUI.EndChangeCheck()) serializedPropertyMyInt.intValue = newValue; } serializedObject.ApplyModifiedProperties(); }}public class MixedValueComponentTest : MonoBehaviour{ public int MyInt;}
Additional Resources: EditorGUI.showMixedValue.
Constructors
Constructor | Description |
|---|---|
| MixedValueScope(System.Boolean) | Creates a new EditorGUI.MixedValueScope that determines the start of the group of mixed value controls. |