mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
[unity] Fix multi-edit bug on flipX/flipY inspectors.
This commit is contained in:
parent
4044c81ace
commit
3e997a2765
@ -253,8 +253,8 @@ namespace Spine.Unity.Editor {
|
||||
|
||||
using (new SpineInspectorUtility.IndentScope()) {
|
||||
using (new EditorGUILayout.HorizontalScope()) {
|
||||
initialFlipX.boolValue = EditorGUILayout.ToggleLeft(initialFlipX.displayName, initialFlipX.boolValue, GUILayout.Width(120f));
|
||||
initialFlipY.boolValue = EditorGUILayout.ToggleLeft(initialFlipY.displayName, initialFlipY.boolValue, GUILayout.Width(120f));
|
||||
SpineInspectorUtility.ToggleLeftLayout(initialFlipX);
|
||||
SpineInspectorUtility.ToggleLeftLayout(initialFlipY);
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
|
||||
@ -370,7 +370,6 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
|
||||
override public void OnInspectorGUI () {
|
||||
//serializedObject.Update();
|
||||
bool multi = serializedObject.isEditingMultipleObjects;
|
||||
DrawInspectorGUI(multi);
|
||||
if (serializedObject.ApplyModifiedProperties() || SpineInspectorUtility.UndoRedoPerformed(Event.current)) {
|
||||
|
||||
@ -71,6 +71,40 @@ namespace Spine.Unity.Editor {
|
||||
PropertyFieldWideLabel(property, label, width);
|
||||
}
|
||||
|
||||
/// <summary>Multi-edit-compatible version of EditorGUILayout.ToggleLeft(SerializedProperty)</summary>
|
||||
public static void ToggleLeftLayout (SerializedProperty property, GUIContent label = null, float width = 120f) {
|
||||
if (label == null) label = SpineInspectorUtility.TempContent(property.displayName, tooltip: property.tooltip);
|
||||
|
||||
if (property.hasMultipleDifferentValues) {
|
||||
bool previousShowMixedValue = EditorGUI.showMixedValue;
|
||||
EditorGUI.showMixedValue = true;
|
||||
|
||||
bool clicked = EditorGUILayout.ToggleLeft(label, property.boolValue, GUILayout.Width(width));
|
||||
if (clicked) property.boolValue = true; // Set all values to true when clicked.
|
||||
|
||||
EditorGUI.showMixedValue = previousShowMixedValue;
|
||||
} else {
|
||||
property.boolValue = EditorGUILayout.ToggleLeft(label, property.boolValue, GUILayout.Width(width));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Multi-edit-compatible version of EditorGUILayout.ToggleLeft(SerializedProperty)</summary>
|
||||
public static void ToggleLeft (Rect rect, SerializedProperty property, GUIContent label = null) {
|
||||
if (label == null) label = SpineInspectorUtility.TempContent(property.displayName, tooltip: property.tooltip);
|
||||
|
||||
if (property.hasMultipleDifferentValues) {
|
||||
bool previousShowMixedValue = EditorGUI.showMixedValue;
|
||||
EditorGUI.showMixedValue = true;
|
||||
|
||||
bool clicked = EditorGUI.ToggleLeft(rect, label, property.boolValue);
|
||||
if (clicked) property.boolValue = true; // Set all values to true when clicked.
|
||||
|
||||
EditorGUI.showMixedValue = previousShowMixedValue;
|
||||
} else {
|
||||
property.boolValue = EditorGUI.ToggleLeft(rect, label, property.boolValue);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool UndoRedoPerformed (UnityEngine.Event current) {
|
||||
return current.type == EventType.ValidateCommand && current.commandName == "UndoRedoPerformed";
|
||||
}
|
||||
@ -342,7 +376,7 @@ namespace Spine.Unity.Editor {
|
||||
EditorGUILayout.PropertyField(prop.sortingOrder, OrderInLayerLabel);
|
||||
|
||||
if (applyModifiedProperties && EditorGUI.EndChangeCheck())
|
||||
prop.ApplyModifiedProperties();
|
||||
prop.ApplyModifiedProperties();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@ -99,9 +99,9 @@ namespace Spine.Unity.Editor {
|
||||
EditorGUI.PrefixLabel(rect, SpineInspectorUtility.TempContent("Initial Flip"));
|
||||
rect.x += EditorGUIUtility.labelWidth;
|
||||
rect.width = 30f;
|
||||
initialFlipX.boolValue = EditorGUI.ToggleLeft(rect, SpineInspectorUtility.TempContent("X", tooltip:"initialFlipX"), initialFlipX.boolValue);
|
||||
SpineInspectorUtility.ToggleLeft(rect, initialFlipX, SpineInspectorUtility.TempContent("X", tooltip: "initialFlipX"));
|
||||
rect.x += 35f;
|
||||
initialFlipY.boolValue = EditorGUI.ToggleLeft(rect, SpineInspectorUtility.TempContent("Y", tooltip:"initialFlipY"), initialFlipY.boolValue);
|
||||
SpineInspectorUtility.ToggleLeft(rect, initialFlipY, SpineInspectorUtility.TempContent("Y", tooltip: "initialFlipY"));
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user