From e65f3f61a5990da662fb554e2b266efedc4fe338 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Wed, 24 Jan 2024 17:52:16 +0100 Subject: [PATCH] [unity] PhysicsConstraints: Added Inspector properties to enable or disable applying Transform translation or rotation. --- CHANGELOG.md | 1 + .../Components/SkeletonGraphicInspector.cs | 14 ++ .../Components/SkeletonRendererInspector.cs | 13 ++ .../Editor/GUI/icon-constraintPhysics.png | Bin 0 -> 3561 bytes .../GUI/icon-constraintPhysics.png.meta | 124 ++++++++++++++++++ .../spine-unity/Editor/Utility/Icons.cs | 2 + spine-unity/Assets/Spine/package.json | 2 +- 7 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 spine-unity/Assets/Spine/Editor/spine-unity/Editor/GUI/icon-constraintPhysics.png create mode 100644 spine-unity/Assets/Spine/Editor/spine-unity/Editor/GUI/icon-constraintPhysics.png.meta diff --git a/CHANGELOG.md b/CHANGELOG.md index b210009b0..87f909e4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,7 @@ * Added `Animation Update` mode (called `UpdateTiming` in code) `In Late Update` for `SkeletonAnimation`, `SkeletonMecanim` and `SkeletonGraphic`. This allows you to update the `SkeletonMecanim` skeleton in the same frame that the Mecanim Animator updated its state, which happens between `Update` and `LateUpdate`. * URP Shaders: Added URP "Blend Mode" shader variants for both URP 3D and URP 2D renderers. They are listed under shader name "Universal Render Pipeline/Spine/Blend Modes/" and "Universal Render Pipeline/2D/Spine/Blend Modes/" respectively. * URP Shaders: Added support for [Tint Black](http://en.esotericsoftware.com/spine-slots#Tint-black) functionality at "Blend Modes" Spine URP shaders (2D and 3D shaders). + * 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 Constraints` `Transform Translation` and `Transform Rotation`, or by setting the properties `applyTranslationToPhysics` and `applyRotationToPhysics` at the skeleton component via code. * **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. 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 808c32cc0..13d54786a 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,6 +62,7 @@ namespace Spine.Unity.Editor { SerializedProperty skeletonDataAsset, initialSkinName; SerializedProperty startingAnimation, startingLoop, timeScale, freeze, updateTiming, updateWhenInvisible, unscaledTime, tintBlack, layoutScaleMode, editReferenceRect; + SerializedProperty applyTranslationToPhysics, applyRotationToPhysics; SerializedProperty initialFlipX, initialFlipY; SerializedProperty meshGeneratorSettings; SerializedProperty allowMultipleCanvasRenderers, separatorSlotNames, enableSeparatorSlots, @@ -72,6 +73,10 @@ namespace Spine.Unity.Editor { "If enabled, AnimationState uses unscaled game time (Time.unscaledDeltaTime), " + "running animations independent of e.g. game pause (Time.timeScale). " + "Instance SkeletonAnimation.timeScale will still be applied."); + 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", + "When enabled, the GameObject Transform rotation movement is applied to PhysicsConstraints of the skeleton."); SkeletonGraphic thisSkeletonGraphic; protected bool isInspectingPrefab; @@ -136,6 +141,8 @@ namespace Spine.Unity.Editor { updateWhenInvisible = so.FindProperty("updateWhenInvisible"); layoutScaleMode = so.FindProperty("layoutScaleMode"); editReferenceRect = so.FindProperty("editReferenceRect"); + applyTranslationToPhysics = so.FindProperty("applyTranslationToPhysics"); + applyRotationToPhysics = so.FindProperty("applyRotationToPhysics"); meshGeneratorSettings = so.FindProperty("meshGenerator").FindPropertyRelative("settings"); meshGeneratorSettings.isExpanded = SkeletonRendererInspector.advancedFoldout; @@ -307,6 +314,13 @@ namespace Spine.Unity.Editor { EditorGUILayout.Space(); SeparatorsField(separatorSlotNames, enableSeparatorSlots, updateSeparatorPartLocation, updateSeparatorPartScale); + + EditorGUILayout.Space(); + using (new SpineInspectorUtility.LabelWidthScope()) { + EditorGUILayout.LabelField(SpineInspectorUtility.TempContent("Physics Constraints", SpineEditorUtilities.Icons.constraintPhysics), EditorStyles.boldLabel); + EditorGUILayout.PropertyField(applyTranslationToPhysics, ApplyTranslationToPhysicsLabel); + EditorGUILayout.PropertyField(applyRotationToPhysics, ApplyRotationToPhysicsLabel); + } } } 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 04fb07f2f..210d3c48c 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,6 +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 SpineInspectorUtility.SerializedSortingProperties sortingProperties; protected bool wasInitParameterChanged = false; protected bool requireRepaint = false; @@ -87,6 +88,11 @@ namespace Spine.Unity.Editor { protected GUIContent MaskMaterialsHeadingLabel, MaskMaterialsNoneLabel, MaskMaterialsInsideLabel, MaskMaterialsOutsideLabel; protected GUIContent SetMaterialButtonLabel, ClearMaterialButtonLabel, DeleteMaterialButtonLabel; + 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", + "When enabled, the GameObject Transform rotation movement is applied to PhysicsConstraints of the skeleton."); + const string ReloadButtonString = "Reload"; static GUILayoutOption reloadButtonWidth; static GUILayoutOption ReloadButtonWidth { get { return reloadButtonWidth = reloadButtonWidth ?? GUILayout.Width(GUI.skin.label.CalcSize(new GUIContent(ReloadButtonString)).x + 20); } } @@ -161,6 +167,8 @@ namespace Spine.Unity.Editor { maskMaterialsNone = so.FindProperty("maskMaterials.materialsMaskDisabled"); maskMaterialsInside = so.FindProperty("maskMaterials.materialsInsideMask"); maskMaterialsOutside = so.FindProperty("maskMaterials.materialsOutsideMask"); + applyTranslationToPhysics = so.FindProperty("applyTranslationToPhysics"); + applyRotationToPhysics = so.FindProperty("applyRotationToPhysics"); separatorSlotNames = so.FindProperty("separatorSlotNames"); separatorSlotNames.isExpanded = true; @@ -406,6 +414,11 @@ namespace Spine.Unity.Editor { differentMaskModesSelected, allowDelete: true, isActiveMaterial: activeMaskInteractionValue == (int)SpriteMaskInteraction.VisibleOutsideMask); } #endif + using (new SpineInspectorUtility.LabelWidthScope()) { + EditorGUILayout.LabelField(SpineInspectorUtility.TempContent("Physics Constraints", SpineEditorUtilities.Icons.constraintPhysics), EditorStyles.boldLabel); + EditorGUILayout.PropertyField(applyTranslationToPhysics, ApplyTranslationToPhysicsLabel); + EditorGUILayout.PropertyField(applyRotationToPhysics, ApplyRotationToPhysicsLabel); + } EditorGUILayout.Space(); diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/GUI/icon-constraintPhysics.png b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/GUI/icon-constraintPhysics.png new file mode 100644 index 0000000000000000000000000000000000000000..703732ada3254be8245e34071b870391dc4f5112 GIT binary patch literal 3561 zcmVKLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0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dQhZ7A_}r`QEO6TFTq;qiU{qYR@+rXlSb3l&2DznnVp%;WITu- zLi$ec@bR7AQ^GK0t7Nm;q-9y-uIr{Ekx0=r&51&xP}!zN{bz_*4eb0Ac+xFO2oCFvh9qsUaKWW?cnCrSJAw)R{g5-Su zFZO4*<2nJ3*C3rvpHfw|q-k17N?FS1^JOIrL$cXya?PsVc=)*p{STOU&IXsx*7^OK zL%Ce$@QGfkx7TUZVcmtL>mj;~A2AGLRswjQm+Bu9#M=cQzVQdKc$E6eIvqVK>7)H5 zA8Ns>d3=AqOlz0MlcNbHU%N9Ii9|XjfTAcg?glih0J{!^KF_?AVCU`_^Z8qR{m~LH zyna95om(ReLv{_dphpA3Fl-k9nx+*Ot_AcBHnZyy$DyT=-&%Z>FoX#1q8hal$~wFjayeU}%3E z=cg)|ra6(%=gVSvcsNz9R=?bkHJ*L3hy2^WviIN)_T}2B)hpENbrdzgu>z!&%ztcS zR}6GrF9Hb5vc?`CQBx-;2Z@?0KVEeC;N%jmof@y4zK`zR4P?||Wx0WE+idG|N%S^Y zTdPlujEp3u@B7JtJ?#KAx9K#;O?0)1bMIH!wzEnqognk_4(_gc96Hv`qfd7O@X4DC z2UZuo8DSX4?A+8XN|#sp{M|)#&7ki=h0Lp+lou5~eQTMYeyDKyLK#Bk{{?FLzgNl$+>b7xkOYQXYuHwl7}g{x|@wN)=F zTfH%p$&5?0e(KP%E&x7z=Qh3-KM{#UW<1YJ0qDA3EEEc*Ed{w;uETMh1OFYUsi|qo jFpSyh>FM%j_MZU&S}{tfry^>e00000NkvXXu0mjfHf*@s literal 0 HcmV?d00001 diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/GUI/icon-constraintPhysics.png.meta b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/GUI/icon-constraintPhysics.png.meta new file mode 100644 index 000000000..4a8fedb07 --- /dev/null +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/GUI/icon-constraintPhysics.png.meta @@ -0,0 +1,124 @@ +fileFormatVersion: 2 +guid: 10e534174824cb04e8a7ec21825f2827 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 12 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMasterTextureLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 2 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + spritePackingTag: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/Icons.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/Icons.cs index 13864e4bd..9fb5891a8 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/Icons.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/Icons.cs @@ -70,6 +70,7 @@ namespace Spine.Unity.Editor { public static Texture2D constraintTransform; public static Texture2D constraintPath; public static Texture2D constraintIK; + public static Texture2D constraintPhysics; public static Texture2D warning; public static Texture2D skeletonUtility; public static Texture2D hingeChain; @@ -113,6 +114,7 @@ namespace Spine.Unity.Editor { constraintTransform = LoadIcon("icon-constraintTransform.png"); constraintPath = LoadIcon("icon-constraintPath.png"); constraintIK = LoadIcon("icon-constraintIK.png"); + constraintPhysics = LoadIcon("icon-constraintPhysics.png"); warning = LoadIcon("icon-warning.png"); skeletonUtility = LoadIcon("icon-skeletonUtility.png"); diff --git a/spine-unity/Assets/Spine/package.json b/spine-unity/Assets/Spine/package.json index af546ad0c..31f7ac78b 100644 --- a/spine-unity/Assets/Spine/package.json +++ b/spine-unity/Assets/Spine/package.json @@ -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.46", + "version": "4.2.47", "unity": "2018.3", "author": { "name": "Esoteric Software",