From ad825305f0f4f5e15da60c7d7b65f8bbe24ed06f Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Mon, 5 Feb 2024 17:35:02 +0100 Subject: [PATCH] [unity] PhysicsConstraints: Added inspector properties for `Movement relative to`, see previous commit 4266c72. --- .../Editor/Components/SkeletonGraphicInspector.cs | 6 +++++- .../Editor/Components/SkeletonRendererInspector.cs | 10 +++++++--- .../Runtime/spine-unity/Components/SkeletonGraphic.cs | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonGraphicInspector.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonGraphicInspector.cs index 13d54786a..137cb1b47 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonGraphicInspector.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonGraphicInspector.cs @@ -62,7 +62,7 @@ namespace Spine.Unity.Editor { SerializedProperty skeletonDataAsset, initialSkinName; SerializedProperty startingAnimation, startingLoop, timeScale, freeze, updateTiming, updateWhenInvisible, unscaledTime, tintBlack, layoutScaleMode, editReferenceRect; - SerializedProperty applyTranslationToPhysics, applyRotationToPhysics; + SerializedProperty applyTranslationToPhysics, applyRotationToPhysics, physicsMovementRelativeTo; SerializedProperty initialFlipX, initialFlipY; SerializedProperty meshGeneratorSettings; SerializedProperty allowMultipleCanvasRenderers, separatorSlotNames, enableSeparatorSlots, @@ -77,6 +77,8 @@ namespace Spine.Unity.Editor { "When enabled, the GameObject Transform translation movement is applied to PhysicsConstraints of the skeleton."); readonly GUIContent ApplyRotationToPhysicsLabel = new GUIContent("Transform Rotation", "When enabled, the GameObject Transform rotation movement is applied to PhysicsConstraints of the skeleton."); + readonly GUIContent PhysicsMovementRelativeToLabel = new GUIContent("Movement relative to", + "Reference transform relative to which physics movement will be calculated, or null to use world location."); SkeletonGraphic thisSkeletonGraphic; protected bool isInspectingPrefab; @@ -143,6 +145,7 @@ namespace Spine.Unity.Editor { editReferenceRect = so.FindProperty("editReferenceRect"); applyTranslationToPhysics = so.FindProperty("applyTranslationToPhysics"); applyRotationToPhysics = so.FindProperty("applyRotationToPhysics"); + physicsMovementRelativeTo = so.FindProperty("physicsMovementRelativeTo"); meshGeneratorSettings = so.FindProperty("meshGenerator").FindPropertyRelative("settings"); meshGeneratorSettings.isExpanded = SkeletonRendererInspector.advancedFoldout; @@ -320,6 +323,7 @@ namespace Spine.Unity.Editor { EditorGUILayout.LabelField(SpineInspectorUtility.TempContent("Physics Constraints", SpineEditorUtilities.Icons.constraintPhysics), EditorStyles.boldLabel); EditorGUILayout.PropertyField(applyTranslationToPhysics, ApplyTranslationToPhysicsLabel); EditorGUILayout.PropertyField(applyRotationToPhysics, ApplyRotationToPhysicsLabel); + EditorGUILayout.PropertyField(physicsMovementRelativeTo, PhysicsMovementRelativeToLabel); } } } diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonRendererInspector.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonRendererInspector.cs index 210d3c48c..91026d36b 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonRendererInspector.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonRendererInspector.cs @@ -68,7 +68,7 @@ namespace Spine.Unity.Editor { protected SerializedProperty normals, tangents, zSpacing, pmaVertexColors, tintBlack; // MeshGenerator settings protected SerializedProperty maskInteraction; protected SerializedProperty maskMaterialsNone, maskMaterialsInside, maskMaterialsOutside; - protected SerializedProperty applyTranslationToPhysics, applyRotationToPhysics; + protected SerializedProperty applyTranslationToPhysics, applyRotationToPhysics, physicsMovementRelativeTo; protected SpineInspectorUtility.SerializedSortingProperties sortingProperties; protected bool wasInitParameterChanged = false; protected bool requireRepaint = false; @@ -88,10 +88,12 @@ namespace Spine.Unity.Editor { protected GUIContent MaskMaterialsHeadingLabel, MaskMaterialsNoneLabel, MaskMaterialsInsideLabel, MaskMaterialsOutsideLabel; protected GUIContent SetMaterialButtonLabel, ClearMaterialButtonLabel, DeleteMaterialButtonLabel; - readonly GUIContent ApplyTranslationToPhysicsLabel = new GUIContent ("Transform Translation", + readonly GUIContent ApplyTranslationToPhysicsLabel = new GUIContent("Transform Translation", "When enabled, the GameObject Transform translation movement is applied to PhysicsConstraints of the skeleton."); - readonly GUIContent ApplyRotationToPhysicsLabel = new GUIContent ("Transform Rotation", + readonly GUIContent ApplyRotationToPhysicsLabel = new GUIContent("Transform Rotation", "When enabled, the GameObject Transform rotation movement is applied to PhysicsConstraints of the skeleton."); + readonly GUIContent PhysicsMovementRelativeToLabel = new GUIContent("Movement relative to", + "Reference transform relative to which physics movement will be calculated, or null to use world location."); const string ReloadButtonString = "Reload"; static GUILayoutOption reloadButtonWidth; @@ -169,6 +171,7 @@ namespace Spine.Unity.Editor { maskMaterialsOutside = so.FindProperty("maskMaterials.materialsOutsideMask"); applyTranslationToPhysics = so.FindProperty("applyTranslationToPhysics"); applyRotationToPhysics = so.FindProperty("applyRotationToPhysics"); + physicsMovementRelativeTo = so.FindProperty("physicsMovementRelativeTo"); separatorSlotNames = so.FindProperty("separatorSlotNames"); separatorSlotNames.isExpanded = true; @@ -418,6 +421,7 @@ namespace Spine.Unity.Editor { EditorGUILayout.LabelField(SpineInspectorUtility.TempContent("Physics Constraints", SpineEditorUtilities.Icons.constraintPhysics), EditorStyles.boldLabel); EditorGUILayout.PropertyField(applyTranslationToPhysics, ApplyTranslationToPhysicsLabel); EditorGUILayout.PropertyField(applyRotationToPhysics, ApplyRotationToPhysicsLabel); + EditorGUILayout.PropertyField(physicsMovementRelativeTo, PhysicsMovementRelativeToLabel); } EditorGUILayout.Space(); diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs index aca198152..3c47131a2 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs @@ -389,7 +389,7 @@ namespace Spine.Unity { } } - public virtual void ApplyTransformMovementToPhysics() { + public virtual void ApplyTransformMovementToPhysics () { if (Application.isPlaying) { if (applyTranslationToPhysics) { Vector2 position = GetPhysicsTransformPosition();