[unity] PhysicsConstraints: Added inspector properties for Movement relative to, see previous commit 4266c72.

This commit is contained in:
Harald Csaszar 2024-02-05 17:35:02 +01:00
parent 4266c727cb
commit ad825305f0
3 changed files with 13 additions and 5 deletions

View File

@ -62,7 +62,7 @@ namespace Spine.Unity.Editor {
SerializedProperty skeletonDataAsset, initialSkinName; SerializedProperty skeletonDataAsset, initialSkinName;
SerializedProperty startingAnimation, startingLoop, timeScale, freeze, SerializedProperty startingAnimation, startingLoop, timeScale, freeze,
updateTiming, updateWhenInvisible, unscaledTime, tintBlack, layoutScaleMode, editReferenceRect; updateTiming, updateWhenInvisible, unscaledTime, tintBlack, layoutScaleMode, editReferenceRect;
SerializedProperty applyTranslationToPhysics, applyRotationToPhysics; SerializedProperty applyTranslationToPhysics, applyRotationToPhysics, physicsMovementRelativeTo;
SerializedProperty initialFlipX, initialFlipY; SerializedProperty initialFlipX, initialFlipY;
SerializedProperty meshGeneratorSettings; SerializedProperty meshGeneratorSettings;
SerializedProperty allowMultipleCanvasRenderers, separatorSlotNames, enableSeparatorSlots, 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."); "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."); "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; SkeletonGraphic thisSkeletonGraphic;
protected bool isInspectingPrefab; protected bool isInspectingPrefab;
@ -143,6 +145,7 @@ namespace Spine.Unity.Editor {
editReferenceRect = so.FindProperty("editReferenceRect"); editReferenceRect = so.FindProperty("editReferenceRect");
applyTranslationToPhysics = so.FindProperty("applyTranslationToPhysics"); applyTranslationToPhysics = so.FindProperty("applyTranslationToPhysics");
applyRotationToPhysics = so.FindProperty("applyRotationToPhysics"); applyRotationToPhysics = so.FindProperty("applyRotationToPhysics");
physicsMovementRelativeTo = so.FindProperty("physicsMovementRelativeTo");
meshGeneratorSettings = so.FindProperty("meshGenerator").FindPropertyRelative("settings"); meshGeneratorSettings = so.FindProperty("meshGenerator").FindPropertyRelative("settings");
meshGeneratorSettings.isExpanded = SkeletonRendererInspector.advancedFoldout; meshGeneratorSettings.isExpanded = SkeletonRendererInspector.advancedFoldout;
@ -320,6 +323,7 @@ namespace Spine.Unity.Editor {
EditorGUILayout.LabelField(SpineInspectorUtility.TempContent("Physics Constraints", SpineEditorUtilities.Icons.constraintPhysics), EditorStyles.boldLabel); EditorGUILayout.LabelField(SpineInspectorUtility.TempContent("Physics Constraints", SpineEditorUtilities.Icons.constraintPhysics), EditorStyles.boldLabel);
EditorGUILayout.PropertyField(applyTranslationToPhysics, ApplyTranslationToPhysicsLabel); EditorGUILayout.PropertyField(applyTranslationToPhysics, ApplyTranslationToPhysicsLabel);
EditorGUILayout.PropertyField(applyRotationToPhysics, ApplyRotationToPhysicsLabel); EditorGUILayout.PropertyField(applyRotationToPhysics, ApplyRotationToPhysicsLabel);
EditorGUILayout.PropertyField(physicsMovementRelativeTo, PhysicsMovementRelativeToLabel);
} }
} }
} }

View File

@ -68,7 +68,7 @@ namespace Spine.Unity.Editor {
protected SerializedProperty normals, tangents, zSpacing, pmaVertexColors, tintBlack; // MeshGenerator settings protected SerializedProperty normals, tangents, zSpacing, pmaVertexColors, tintBlack; // MeshGenerator settings
protected SerializedProperty maskInteraction; protected SerializedProperty maskInteraction;
protected SerializedProperty maskMaterialsNone, maskMaterialsInside, maskMaterialsOutside; protected SerializedProperty maskMaterialsNone, maskMaterialsInside, maskMaterialsOutside;
protected SerializedProperty applyTranslationToPhysics, applyRotationToPhysics; protected SerializedProperty applyTranslationToPhysics, applyRotationToPhysics, physicsMovementRelativeTo;
protected SpineInspectorUtility.SerializedSortingProperties sortingProperties; protected SpineInspectorUtility.SerializedSortingProperties sortingProperties;
protected bool wasInitParameterChanged = false; protected bool wasInitParameterChanged = false;
protected bool requireRepaint = false; protected bool requireRepaint = false;
@ -88,10 +88,12 @@ namespace Spine.Unity.Editor {
protected GUIContent MaskMaterialsHeadingLabel, MaskMaterialsNoneLabel, MaskMaterialsInsideLabel, MaskMaterialsOutsideLabel; protected GUIContent MaskMaterialsHeadingLabel, MaskMaterialsNoneLabel, MaskMaterialsInsideLabel, MaskMaterialsOutsideLabel;
protected GUIContent SetMaterialButtonLabel, ClearMaterialButtonLabel, DeleteMaterialButtonLabel; 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."); "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."); "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"; const string ReloadButtonString = "Reload";
static GUILayoutOption reloadButtonWidth; static GUILayoutOption reloadButtonWidth;
@ -169,6 +171,7 @@ namespace Spine.Unity.Editor {
maskMaterialsOutside = so.FindProperty("maskMaterials.materialsOutsideMask"); maskMaterialsOutside = so.FindProperty("maskMaterials.materialsOutsideMask");
applyTranslationToPhysics = so.FindProperty("applyTranslationToPhysics"); applyTranslationToPhysics = so.FindProperty("applyTranslationToPhysics");
applyRotationToPhysics = so.FindProperty("applyRotationToPhysics"); applyRotationToPhysics = so.FindProperty("applyRotationToPhysics");
physicsMovementRelativeTo = so.FindProperty("physicsMovementRelativeTo");
separatorSlotNames = so.FindProperty("separatorSlotNames"); separatorSlotNames = so.FindProperty("separatorSlotNames");
separatorSlotNames.isExpanded = true; separatorSlotNames.isExpanded = true;
@ -418,6 +421,7 @@ namespace Spine.Unity.Editor {
EditorGUILayout.LabelField(SpineInspectorUtility.TempContent("Physics Constraints", SpineEditorUtilities.Icons.constraintPhysics), EditorStyles.boldLabel); EditorGUILayout.LabelField(SpineInspectorUtility.TempContent("Physics Constraints", SpineEditorUtilities.Icons.constraintPhysics), EditorStyles.boldLabel);
EditorGUILayout.PropertyField(applyTranslationToPhysics, ApplyTranslationToPhysicsLabel); EditorGUILayout.PropertyField(applyTranslationToPhysics, ApplyTranslationToPhysicsLabel);
EditorGUILayout.PropertyField(applyRotationToPhysics, ApplyRotationToPhysicsLabel); EditorGUILayout.PropertyField(applyRotationToPhysics, ApplyRotationToPhysicsLabel);
EditorGUILayout.PropertyField(physicsMovementRelativeTo, PhysicsMovementRelativeToLabel);
} }
EditorGUILayout.Space(); EditorGUILayout.Space();

View File

@ -389,7 +389,7 @@ namespace Spine.Unity {
} }
} }
public virtual void ApplyTransformMovementToPhysics() { public virtual void ApplyTransformMovementToPhysics () {
if (Application.isPlaying) { if (Application.isPlaying) {
if (applyTranslationToPhysics) { if (applyTranslationToPhysics) {
Vector2 position = GetPhysicsTransformPosition(); Vector2 position = GetPhysicsTransformPosition();