[unity] PhysicsConstraints: Added Spine Preferences settings Physics Inheritance - Default Position and Default Rotation. See related commit 506c2dd.

This commit is contained in:
Harald Csaszar 2024-02-15 13:49:01 +01:00
parent 506c2dd33a
commit 54735c789b
7 changed files with 48 additions and 3 deletions

View File

@ -56,6 +56,7 @@
* PhysicsConstraints: Skeleton GameObjects now automatically apply Transform translation and rotation to the skeleton's `PhysicsConstraints`. You can disable applying translation or rotation at the Skeleton component Inspector under `Advanced - Physics Inheritance` by setting `Position` to (0,0)and `Rotation` to 0, or by setting the properties `physicsPositionInheritanceFactor` to `Vector2.zero` and `physicsRotationInheritanceFactor` to `0` at the skeleton component via code.
* Added `Physics Constraints` example scene (located in `Spine Examples/Other Examples`) together with `celestial-circus` example skeleton assets. This scene demonstrates Transform movement automatically affecting physics constraints of a skeleton.
* PhysicsConstraints: Skeleton components now allow you to use relative instead of world-space Transform movement by assigning a Transform (typically the parent) to the new `Movement relative to` property. Leave this property at `null` (the default) to use world-space Transform movement for physics.
* PhysicsConstraints: Added Spine Preferences settings `Editor Instantiation` - `Physics Inheritance` - `Default Position` and `Default Rotation` to initialize skeletons physics settings with the desired Transform position and rotation inheritance factors when added to a scene via drag-and-drop.
* **Breaking changes**
* Changed `SpineShaderWithOutlineGUI` outline related methods from `private` to `protected virtual` to allow for custom shader GUI subclasses to switch to different outline shaders.

View File

@ -76,7 +76,7 @@ namespace Spine.Unity.Editor {
readonly GUIContent PhysicsPositionInheritanceFactorLabel = new GUIContent("Position",
"When set to non-zero, Transform position movement in X and Y direction is applied to skeleton " +
"PhysicsConstraints, multiplied by these " +
"\nX and Y scale factors to the right. Typical values are " +
"\nX and Y scale factors to the right. Typical (X,Y) values are " +
"\n(1,1) to apply XY movement normally, " +
"\n(2,2) to apply movement with double intensity, " +
"\n(1,0) to apply only horizontal movement, or" +
@ -564,6 +564,8 @@ namespace Spine.Unity.Editor {
graphic.MeshGenerator.settings.zSpacing = SpineEditorUtilities.Preferences.defaultZSpacing;
graphic.startingLoop = SpineEditorUtilities.Preferences.defaultInstantiateLoop;
graphic.PhysicsPositionInheritanceFactor = SpineEditorUtilities.Preferences.defaultPhysicsPositionInheritance;
graphic.PhysicsRotationInheritanceFactor = SpineEditorUtilities.Preferences.defaultPhysicsRotationInheritance;
graphic.Initialize(false);
if (skin != null) graphic.Skeleton.SetSkin(skin);
graphic.initialSkinName = skin.Name;

View File

@ -91,7 +91,7 @@ namespace Spine.Unity.Editor {
readonly GUIContent PhysicsPositionInheritanceFactorLabel = new GUIContent("Position",
"When set to non-zero, Transform position movement in X and Y direction is applied to skeleton " +
"PhysicsConstraints, multiplied by these " +
"\nX and Y scale factors to the right. Typical values are " +
"\nX and Y scale factors to the right. Typical (X,Y) values are " +
"\n(1,1) to apply XY movement normally, " +
"\n(2,2) to apply movement with double intensity, " +
"\n(1,0) to apply only horizontal movement, or" +

View File

@ -1301,6 +1301,8 @@ namespace Spine.Unity.Editor {
skeletonRenderer.pmaVertexColors = pmaVertexColors;
skeletonRenderer.tintBlack = tintBlack;
skeletonRenderer.zSpacing = SpineEditorUtilities.Preferences.defaultZSpacing;
skeletonRenderer.PhysicsPositionInheritanceFactor = SpineEditorUtilities.Preferences.defaultPhysicsPositionInheritance;
skeletonRenderer.PhysicsRotationInheritanceFactor = SpineEditorUtilities.Preferences.defaultPhysicsRotationInheritance;
SkeletonData data = skeletonDataAsset.GetSkeletonData(false);
bool noSkins = data.DefaultSkin == null && (data.Skins == null || data.Skins.Count == 0); // Support attachmentless/skinless SkeletonData.

View File

@ -115,6 +115,13 @@ namespace Spine.Unity.Editor {
const string DEFAULT_INSTANTIATE_LOOP_KEY = "SPINE_DEFAULT_INSTANTIATE_LOOP";
public static bool defaultInstantiateLoop = SpinePreferences.DEFAULT_DEFAULT_INSTANTIATE_LOOP;
const string DEFAULT_PHYSICS_POSITION_INHERITANCE_X_KEY = "SPINE_DEFAULT_PHYSICS_POSITION_INHERITANCE_X";
const string DEFAULT_PHYSICS_POSITION_INHERITANCE_Y_KEY = "SPINE_DEFAULT_PHYSICS_POSITION_INHERITANCE_Y";
public static Vector2 defaultPhysicsPositionInheritance = SpinePreferences.DEFAULT_DEFAULT_PHYSICS_POSITION_INHERITANCE;
const string DEFAULT_PHYSICS_ROTATION_INHERITANCE_KEY = "SPINE_DEFAULT_PHYSICS_ROTATION_INHERITANCE";
public static float defaultPhysicsRotationInheritance = SpinePreferences.DEFAULT_DEFAULT_PHYSICS_ROTATION_INHERITANCE;
const string SHOW_HIERARCHY_ICONS_KEY = "SPINE_SHOW_HIERARCHY_ICONS";
public static bool showHierarchyIcons = SpinePreferences.DEFAULT_SHOW_HIERARCHY_ICONS;
@ -191,6 +198,10 @@ namespace Spine.Unity.Editor {
defaultMix = EditorPrefs.GetFloat(DEFAULT_MIX_KEY, SpinePreferences.DEFAULT_DEFAULT_MIX);
defaultScale = EditorPrefs.GetFloat(DEFAULT_SCALE_KEY, SpinePreferences.DEFAULT_DEFAULT_SCALE);
defaultZSpacing = EditorPrefs.GetFloat(DEFAULT_ZSPACING_KEY, SpinePreferences.DEFAULT_DEFAULT_ZSPACING);
defaultInstantiateLoop = EditorPrefs.GetBool(DEFAULT_INSTANTIATE_LOOP_KEY, SpinePreferences.DEFAULT_DEFAULT_INSTANTIATE_LOOP);
defaultPhysicsPositionInheritance.x = EditorPrefs.GetFloat(DEFAULT_PHYSICS_POSITION_INHERITANCE_X_KEY, SpinePreferences.DEFAULT_DEFAULT_PHYSICS_POSITION_INHERITANCE.x);
defaultPhysicsPositionInheritance.y = EditorPrefs.GetFloat(DEFAULT_PHYSICS_POSITION_INHERITANCE_Y_KEY, SpinePreferences.DEFAULT_DEFAULT_PHYSICS_POSITION_INHERITANCE.y);
defaultPhysicsRotationInheritance = EditorPrefs.GetFloat(DEFAULT_PHYSICS_ROTATION_INHERITANCE_KEY, SpinePreferences.DEFAULT_DEFAULT_PHYSICS_ROTATION_INHERITANCE);
defaultShader = EditorPrefs.GetString(DEFAULT_SHADER_KEY, SpinePreferences.DEFAULT_DEFAULT_SHADER);
showHierarchyIcons = EditorPrefs.GetBool(SHOW_HIERARCHY_ICONS_KEY, SpinePreferences.DEFAULT_SHOW_HIERARCHY_ICONS);
reloadAfterPlayMode = EditorPrefs.GetBool(RELOAD_AFTER_PLAYMODE_KEY, SpinePreferences.DEFAULT_RELOAD_AFTER_PLAYMODE);
@ -216,6 +227,10 @@ namespace Spine.Unity.Editor {
newPreferences.defaultMix = EditorPrefs.GetFloat(DEFAULT_MIX_KEY, SpinePreferences.DEFAULT_DEFAULT_MIX);
newPreferences.defaultScale = EditorPrefs.GetFloat(DEFAULT_SCALE_KEY, SpinePreferences.DEFAULT_DEFAULT_SCALE);
newPreferences.defaultZSpacing = EditorPrefs.GetFloat(DEFAULT_ZSPACING_KEY, SpinePreferences.DEFAULT_DEFAULT_ZSPACING);
newPreferences.defaultInstantiateLoop = EditorPrefs.GetBool(DEFAULT_INSTANTIATE_LOOP_KEY, SpinePreferences.DEFAULT_DEFAULT_INSTANTIATE_LOOP);
newPreferences.defaultPhysicsPositionInheritance.x = EditorPrefs.GetFloat(DEFAULT_PHYSICS_POSITION_INHERITANCE_X_KEY, SpinePreferences.DEFAULT_DEFAULT_PHYSICS_POSITION_INHERITANCE.x);
newPreferences.defaultPhysicsPositionInheritance.y = EditorPrefs.GetFloat(DEFAULT_PHYSICS_POSITION_INHERITANCE_Y_KEY, SpinePreferences.DEFAULT_DEFAULT_PHYSICS_POSITION_INHERITANCE.y);
newPreferences.defaultPhysicsRotationInheritance = EditorPrefs.GetFloat(DEFAULT_PHYSICS_ROTATION_INHERITANCE_KEY, SpinePreferences.DEFAULT_DEFAULT_PHYSICS_ROTATION_INHERITANCE);
newPreferences.defaultShader = EditorPrefs.GetString(DEFAULT_SHADER_KEY, SpinePreferences.DEFAULT_DEFAULT_SHADER);
newPreferences.showHierarchyIcons = EditorPrefs.GetBool(SHOW_HIERARCHY_ICONS_KEY, SpinePreferences.DEFAULT_SHOW_HIERARCHY_ICONS);
newPreferences.reloadAfterPlayMode = EditorPrefs.GetBool(RELOAD_AFTER_PLAYMODE_KEY, SpinePreferences.DEFAULT_RELOAD_AFTER_PLAYMODE);
@ -236,6 +251,10 @@ namespace Spine.Unity.Editor {
EditorPrefs.SetFloat(DEFAULT_MIX_KEY, preferences.defaultMix);
EditorPrefs.SetFloat(DEFAULT_SCALE_KEY, preferences.defaultScale);
EditorPrefs.SetFloat(DEFAULT_ZSPACING_KEY, preferences.defaultZSpacing);
EditorPrefs.SetBool(DEFAULT_INSTANTIATE_LOOP_KEY, preferences.defaultInstantiateLoop);
EditorPrefs.SetFloat(DEFAULT_PHYSICS_POSITION_INHERITANCE_X_KEY, preferences.defaultPhysicsPositionInheritance.x);
EditorPrefs.SetFloat(DEFAULT_PHYSICS_POSITION_INHERITANCE_Y_KEY, preferences.defaultPhysicsPositionInheritance.y);
EditorPrefs.SetFloat(DEFAULT_PHYSICS_ROTATION_INHERITANCE_KEY, preferences.defaultPhysicsRotationInheritance);
EditorPrefs.SetString(DEFAULT_SHADER_KEY, preferences.defaultShader);
EditorPrefs.SetBool(SHOW_HIERARCHY_ICONS_KEY, preferences.showHierarchyIcons);
EditorPrefs.SetBool(RELOAD_AFTER_PLAYMODE_KEY, preferences.reloadAfterPlayMode);
@ -336,6 +355,16 @@ namespace Spine.Unity.Editor {
EditorPrefs.SetFloat(DEFAULT_ZSPACING_KEY, defaultZSpacing);
SpineEditorUtilities.BoolPrefsField(ref defaultInstantiateLoop, DEFAULT_INSTANTIATE_LOOP_KEY, new GUIContent("Default Loop", "Spawn Spine GameObjects with loop enabled."));
EditorGUILayout.LabelField("Physics Inheritance");
using (new SpineInspectorUtility.IndentScope()) {
float positionX = preferences.defaultPhysicsPositionInheritance.x;
float positionY = preferences.defaultPhysicsPositionInheritance.y;
SpineEditorUtilities.FloatPrefsField(ref positionX, DEFAULT_PHYSICS_POSITION_INHERITANCE_X_KEY, new GUIContent("Default Position X", "The Default Physics Inheritance - Position X factor."));
SpineEditorUtilities.FloatPrefsField(ref positionY, DEFAULT_PHYSICS_POSITION_INHERITANCE_Y_KEY, new GUIContent("Default Position Y", "The Default Physics Inheritance - Position Y factor."));
defaultPhysicsPositionInheritance = new Vector2(positionX, positionY);
SpineEditorUtilities.FloatPrefsField(ref defaultPhysicsRotationInheritance, DEFAULT_PHYSICS_ROTATION_INHERITANCE_Y_KEY, new GUIContent("Default Rotation", "The Default Physics Inheritance - Rotation factor."));
}
}
EditorGUILayout.Space();

View File

@ -77,6 +77,12 @@ namespace Spine.Unity.Editor {
internal const bool DEFAULT_DEFAULT_INSTANTIATE_LOOP = true;
public bool defaultInstantiateLoop = DEFAULT_DEFAULT_INSTANTIATE_LOOP;
internal static readonly Vector2 DEFAULT_DEFAULT_PHYSICS_POSITION_INHERITANCE = Vector2.one;
public Vector2 defaultPhysicsPositionInheritance = DEFAULT_DEFAULT_PHYSICS_POSITION_INHERITANCE;
internal const float DEFAULT_DEFAULT_PHYSICS_ROTATION_INHERITANCE = 1f;
public float defaultPhysicsRotationInheritance = DEFAULT_DEFAULT_PHYSICS_ROTATION_INHERITANCE;
internal const bool DEFAULT_SHOW_HIERARCHY_ICONS = true;
public bool showHierarchyIcons = DEFAULT_SHOW_HIERARCHY_ICONS;
@ -314,6 +320,11 @@ namespace Spine.Unity.Editor {
{
EditorGUILayout.Slider(settings.FindProperty("defaultZSpacing"), -0.1f, 0f, new GUIContent("Default Slot Z-Spacing"));
EditorGUILayout.PropertyField(settings.FindProperty("defaultInstantiateLoop"), new GUIContent("Default Loop", "Spawn Spine GameObjects with loop enabled."));
EditorGUILayout.LabelField("Physics Inheritance");
using (new SpineInspectorUtility.IndentScope()) {
EditorGUILayout.PropertyField(settings.FindProperty("defaultPhysicsPositionInheritance"), new GUIContent("Default Position", "The Default Physics Inheritance - Position factor."));
EditorGUILayout.PropertyField(settings.FindProperty("defaultPhysicsRotationInheritance"), new GUIContent("Default Rotation", "The Default Physics Inheritance - Rotation factor."));
}
}
EditorGUILayout.Space();

View File

@ -2,7 +2,7 @@
"name": "com.esotericsoftware.spine.spine-unity",
"displayName": "spine-unity Runtime",
"description": "This plugin provides the spine-unity runtime core.",
"version": "4.2.50",
"version": "4.2.51",
"unity": "2018.3",
"author": {
"name": "Esoteric Software",