mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
[unity] Added SkeletonGraphic.MeshScale property to allow access to calculated mesh scale.
This commit is contained in:
parent
723f689527
commit
cbe0e5433a
@ -102,7 +102,8 @@
|
|||||||
* Added support for light cookies at `Universal Render Pipeline/Spine/Sprite` shader.
|
* Added support for light cookies at `Universal Render Pipeline/Spine/Sprite` shader.
|
||||||
* Timeline extension package: An additional Spine preferences parameter `Timeline` - `Default Mix Duration` has been added, setting newly added `SpineAnimationStateClip` clips accordingly, defaults to false. This Spine preferences parameter can be enabled to default to the previous behaviour before this update.
|
* Timeline extension package: An additional Spine preferences parameter `Timeline` - `Default Mix Duration` has been added, setting newly added `SpineAnimationStateClip` clips accordingly, defaults to false. This Spine preferences parameter can be enabled to default to the previous behaviour before this update.
|
||||||
* Tint Black: Added support for [Tint Black](http://en.esotericsoftware.com/spine-slots#Tint-black) functionality at all Spine URP shaders (2D and 3D shaders) and at all standard pipeline `Spine/Sprite` shaders. This feature can be enabled via the `Tint Black` material parameter in the Inspector. Note: The URP Sprite shaders provided in the Spine URP Shaders extension UPM package require the latest version of the spine-unity runtime (package version 4.1.12, 2023-05-31 or newer) to display the added material parameters in the Inspector GUI.
|
* Tint Black: Added support for [Tint Black](http://en.esotericsoftware.com/spine-slots#Tint-black) functionality at all Spine URP shaders (2D and 3D shaders) and at all standard pipeline `Spine/Sprite` shaders. This feature can be enabled via the `Tint Black` material parameter in the Inspector. Note: The URP Sprite shaders provided in the Spine URP Shaders extension UPM package require the latest version of the spine-unity runtime (package version 4.1.12, 2023-05-31 or newer) to display the added material parameters in the Inspector GUI.
|
||||||
|
* Added `SkeletonGraphic.MeshScale` property to allow access to calculated mesh scale. `MeshScale` is based on (1) Canvas pixels per unit, and (2) `RectTransform` bounds when using `Layout Scale Mode` other than `None` at `SkeletonGraphic` which scales the skeleton mesh to fit the parent `RectTransform` bounds accordingly.
|
||||||
|
|
||||||
* **Breaking changes**
|
* **Breaking changes**
|
||||||
* Made `SkeletonGraphic.unscaledTime` parameter protected, use the new property `UnscaledTime` instead.
|
* Made `SkeletonGraphic.unscaledTime` parameter protected, use the new property `UnscaledTime` instead.
|
||||||
* `SkeletonGraphic` `OnRebuild` callback delegate is now issued after the skeleton has been initialized, before the `AnimationState` component is initialized. This makes behaviour consistent with `SkeletonAnimation` and `SkeletonMecanim` component behaviour. Use the new callback `OnAnimationRebuild` if you want to receive a callback after the `SkeletonGraphic` `AnimationState` has been initialized.
|
* `SkeletonGraphic` `OnRebuild` callback delegate is now issued after the skeleton has been initialized, before the `AnimationState` component is initialized. This makes behaviour consistent with `SkeletonAnimation` and `SkeletonMecanim` component behaviour. Use the new callback `OnAnimationRebuild` if you want to receive a callback after the `SkeletonGraphic` `AnimationState` has been initialized.
|
||||||
|
|||||||
@ -54,7 +54,7 @@ namespace Spine.Unity.Examples {
|
|||||||
Vector2 localRectPosition;
|
Vector2 localRectPosition;
|
||||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(
|
RectTransformUtility.ScreenPointToLocalPointInRectangle(
|
||||||
skeletonGraphic.rectTransform, mousePosition, null, out localRectPosition);
|
skeletonGraphic.rectTransform, mousePosition, null, out localRectPosition);
|
||||||
Vector3 skeletonSpacePoint = localRectPosition / canvas.referencePixelsPerUnit;
|
Vector3 skeletonSpacePoint = localRectPosition / skeletonGraphic.MeshScale;
|
||||||
skeletonSpacePoint.x *= skeletonGraphic.Skeleton.ScaleX;
|
skeletonSpacePoint.x *= skeletonGraphic.Skeleton.ScaleX;
|
||||||
skeletonSpacePoint.y *= skeletonGraphic.Skeleton.ScaleY;
|
skeletonSpacePoint.y *= skeletonGraphic.Skeleton.ScaleY;
|
||||||
bone.SetLocalPosition(skeletonSpacePoint);
|
bone.SetLocalPosition(skeletonSpacePoint);
|
||||||
|
|||||||
@ -67,6 +67,8 @@ namespace Spine.Unity {
|
|||||||
public bool startingLoop;
|
public bool startingLoop;
|
||||||
public float timeScale = 1f;
|
public float timeScale = 1f;
|
||||||
public bool freeze;
|
public bool freeze;
|
||||||
|
protected float meshScale = 1f;
|
||||||
|
public float MeshScale { get { return meshScale; } }
|
||||||
|
|
||||||
public enum LayoutMode {
|
public enum LayoutMode {
|
||||||
None = 0,
|
None = 0,
|
||||||
@ -780,13 +782,13 @@ namespace Spine.Unity {
|
|||||||
meshGenerator.BuildMeshWithArrays(currentInstructions, updateTriangles);
|
meshGenerator.BuildMeshWithArrays(currentInstructions, updateTriangles);
|
||||||
}
|
}
|
||||||
|
|
||||||
float scale = (canvas == null) ? 100 : canvas.referencePixelsPerUnit;
|
meshScale = (canvas == null) ? 100 : canvas.referencePixelsPerUnit;
|
||||||
if (layoutScaleMode != LayoutMode.None) {
|
if (layoutScaleMode != LayoutMode.None) {
|
||||||
scale *= referenceScale;
|
meshScale *= referenceScale;
|
||||||
if (!EditReferenceRect)
|
if (!EditReferenceRect)
|
||||||
scale *= GetLayoutScale(layoutScaleMode);
|
meshScale *= GetLayoutScale(layoutScaleMode);
|
||||||
}
|
}
|
||||||
meshGenerator.ScaleVertexData(scale);
|
meshGenerator.ScaleVertexData(meshScale);
|
||||||
if (OnPostProcessVertices != null) OnPostProcessVertices.Invoke(this.meshGenerator.Buffers);
|
if (OnPostProcessVertices != null) OnPostProcessVertices.Invoke(this.meshGenerator.Buffers);
|
||||||
|
|
||||||
Mesh mesh = smartMesh.mesh;
|
Mesh mesh = smartMesh.mesh;
|
||||||
@ -858,11 +860,11 @@ namespace Spine.Unity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void UpdateMeshMultipleCanvasRenderers (SkeletonRendererInstruction currentInstructions) {
|
protected void UpdateMeshMultipleCanvasRenderers (SkeletonRendererInstruction currentInstructions) {
|
||||||
float scale = (canvas == null) ? 100 : canvas.referencePixelsPerUnit;
|
meshScale = (canvas == null) ? 100 : canvas.referencePixelsPerUnit;
|
||||||
if (layoutScaleMode != LayoutMode.None) {
|
if (layoutScaleMode != LayoutMode.None) {
|
||||||
scale *= referenceScale;
|
meshScale *= referenceScale;
|
||||||
if (!EditReferenceRect)
|
if (!EditReferenceRect)
|
||||||
scale *= GetLayoutScale(layoutScaleMode);
|
meshScale *= GetLayoutScale(layoutScaleMode);
|
||||||
}
|
}
|
||||||
// Generate meshes.
|
// Generate meshes.
|
||||||
int submeshCount = currentInstructions.submeshInstructions.Count;
|
int submeshCount = currentInstructions.submeshInstructions.Count;
|
||||||
@ -884,7 +886,7 @@ namespace Spine.Unity {
|
|||||||
meshGenerator.AddSubmesh(submeshInstructionItem);
|
meshGenerator.AddSubmesh(submeshInstructionItem);
|
||||||
|
|
||||||
Mesh targetMesh = meshesItems[i];
|
Mesh targetMesh = meshesItems[i];
|
||||||
meshGenerator.ScaleVertexData(scale);
|
meshGenerator.ScaleVertexData(meshScale);
|
||||||
if (OnPostProcessVertices != null) OnPostProcessVertices.Invoke(this.meshGenerator.Buffers);
|
if (OnPostProcessVertices != null) OnPostProcessVertices.Invoke(this.meshGenerator.Buffers);
|
||||||
meshGenerator.FillVertexData(targetMesh);
|
meshGenerator.FillVertexData(targetMesh);
|
||||||
meshGenerator.FillTriangles(targetMesh);
|
meshGenerator.FillTriangles(targetMesh);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user