Version: 5.4
public static bool showMixedValue ;

説明

次のコントロールが与える編集する複数の異なる値の Appearance を作成します。

これはカスタムのエディターを作成するときや複数のオブジェクトの編集をサポートしながら GUI で標準ではない方法で値を表したいとき便利です。

	// This example shows a custom inspector for an object "MyVessel".
	// MyVessel has a boolean variable isFast but we want to show it
	// as a dropdown instead of as a toggle.
	
	enum SpeedOption { Slow, Fast }
	
	@CustomEditor (MyVessel)
	@CanEditMultipleObjects
	class MyVesselEditor extends Editor {
		var isFastProp : SerializedProperty;
		
		function OnEnable () {
			isFastProp = serializedObject.FindProperty ("isFast");
		}
		
		function OnInspectorGUI () {
			serializedObject.Update ();
			
			// Show the isFast boolean the standard way - as a toggle:
			EditorGUILayout.PropertyField (isFastProp);
			
			// Show the isFast boolean as a dropdown using the SpeedOption enum defined above:
			
			// Check if the value was changed inside this block
			EditorGUI.BeginChangeCheck ();
			
			// If the isFast property represent multiple different values, the dropdown should show that:
			EditorGUI.showMixedValue = isFastProp.hasMultipleDifferentValues;
			
			// Convert the isFast boolean to an enum value
			var speedOptionEnumValue : SpeedOption;
			if (isFastProp.boolValue == true)
				speedOptionEnumValue = SpeedOption.Fast;
			else
				speedOptionEnumValue = SpeedOption.Slow;
			
			// Present the enum value in a dropdown:
			speedOptionEnumValue = EditorGUILayout.EnumPopup ("Speed", speedOptionEnumValue);
			
			// Set showMixedValue to false so it doesn't affect the following controls, if any:
			EditorGUI.showMixedValue = false;
			
			// If the value was changed inside this block, apply the new value to all the objects:
			if (EditorGUI.EndChangeCheck ())
				isFastProp.boolValue = (speedOptionEnumValue == SpeedOption.Fast ? true : false);
			
			serializedObject.ApplyModifiedProperties ();
		}
	}
	// This is the MyVessel script used above
	
	var isFast : boolean = false;
	
	function Update () {
		// Update logic here...
	}