Skip to content

Commit

Permalink
[unity] Fixed SkeletonGraphicRenderTexture RenderTexture being distor…
Browse files Browse the repository at this point in the history
…ted. Closes #2513. Minor breaking: Changed type and name of protected member RawImage quadRawImage to SkeletonSubmeshGraphic quadMaskableGraphic.
  • Loading branch information
HaraldCsaszar committed Apr 30, 2024
1 parent b41e937 commit bab69e2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -165,6 +165,7 @@
- SkeletonGraphic Materials: Since the addition of new material sets for the `CanvasGroupCompatible` parameters, the default SkeletonGraphic materials all have `CanvasGroup Compatible` disabled. Please assign the respective material from the `CanvasGroupCompatible` material subdirectory if you want `CanvasGroup Compatible` enabled at your SkeletonGraphic.
- SkeletonGraphic: The parameter `SkeletonGraphic.MeshGenerator.settings.canvasGroupTintBlack` was changed to `canvasGroupCompatible` to help with auto-detecting correct Vertex Data and Material settings. Set the parameter to true if the SkeletonGraphic component is located below a `CanvasGroup` component. The parameter value is automatically migrated from `canvasGroupTintBlack`.
- Inspector: String attribute `SpineSkin()` now allows to include `<None>` in the list of parameters. Previously the `includeNone=true` parameter of the `SpineSkin()` attribute defaulted to `true` but was ignored. Now it defaults to `false` and has an effect on the list. Only the Inspector GUI is affected by this behaviour change.
- `SkeletonGraphicRenderTexture` example component: `protected RawImage quadRawImage` was changed to `protected SkeletonSubmeshGraphic quadMaskableGraphic` for a bugfix. This is only relevant for subclasses of `SkeletonGraphicRenderTexture` or when querying the `RawImage` component via e.g. `skeletonGraphicRenderTexture.quad.GetComponent<RawImage>()`.

- **Changes of default values**

Expand Down
Expand Up @@ -40,7 +40,7 @@ namespace Spine.Unity.Examples {

/// <summary>
/// When enabled, this component renders a skeleton to a RenderTexture and
/// then draws this RenderTexture at a UI RawImage quad of the same size.
/// then draws this RenderTexture at a UI SkeletonSubmeshGraphic quad of the same size.
/// This allows changing transparency at a single quad, which produces a more
/// natural fadeout effect.
/// Note: It is recommended to keep this component disabled as much as possible
Expand All @@ -64,7 +64,7 @@ public struct TextureMaterialPair {
protected SkeletonGraphic skeletonGraphic;
public List<TextureMaterialPair> meshRendererMaterialForTexture = new List<TextureMaterialPair>();
protected CanvasRenderer quadCanvasRenderer;
protected RawImage quadRawImage;
protected SkeletonSubmeshGraphic quadMaskableGraphic;
protected readonly Vector3[] worldCorners = new Vector3[4];

protected override void Awake () {
Expand All @@ -79,10 +79,10 @@ public struct TextureMaterialPair {
}

void CreateQuadChild () {
quad = new GameObject(this.name + " RenderTexture", typeof(CanvasRenderer), typeof(RawImage));
quad = new GameObject(this.name + " RenderTexture", typeof(CanvasRenderer), typeof(SkeletonSubmeshGraphic));
quad.transform.SetParent(this.transform.parent, false);
quadCanvasRenderer = quad.GetComponent<CanvasRenderer>();
quadRawImage = quad.GetComponent<RawImage>();
quadMaskableGraphic = quad.GetComponent<SkeletonSubmeshGraphic>();

quadMesh = new Mesh();
quadMesh.MarkDynamic();
Expand Down Expand Up @@ -212,12 +212,12 @@ public struct TextureMaterialPair {
}

protected void SetupQuad () {
quadRawImage.texture = this.renderTexture;
quadRawImage.color = color;
quadCanvasRenderer.SetMaterial(Canvas.GetDefaultCanvasMaterial(), this.renderTexture);
quadMaskableGraphic.color = color;
quadCanvasRenderer.SetColor(color);

RectTransform srcRectTransform = skeletonGraphic.rectTransform;
RectTransform dstRectTransform = quadRawImage.rectTransform;
RectTransform dstRectTransform = quadMaskableGraphic.rectTransform;

dstRectTransform.anchorMin = srcRectTransform.anchorMin;
dstRectTransform.anchorMax = srcRectTransform.anchorMax;
Expand Down
2 changes: 1 addition & 1 deletion spine-unity/Assets/Spine Examples/package.json
Expand Up @@ -2,7 +2,7 @@
"name": "com.esotericsoftware.spine.spine-unity-examples",
"displayName": "spine-unity Runtime Examples",
"description": "This plugin provides example scenes and scripts for the spine-unity runtime.",
"version": "4.2.28",
"version": "4.2.29",
"unity": "2018.3",
"author": {
"name": "Esoteric Software",
Expand Down

0 comments on commit bab69e2

Please sign in to comment.