mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-11 17:48:45 +08:00
[unity] Fixed white image at first frame when using multiple canvas renderers. Replaced RawImage at additional SkeletonGraphic renderers with more resource friendly custom component.
This commit is contained in:
parent
cf35d1e982
commit
214c778bac
@ -54,6 +54,7 @@
|
||||
* Corrected all `Outline` shaders outline thickness when `Advanced - Sample 8 Neighbourhood` is disabled (thus using `4 Neighbourhood`). Previously weighting was incorrectly thick (4x as thick) compared to 8 neighbourhood, now it is more consistent. This might require adjustment of all your outline materials where `Sample 8 Neighbourhood` is disabled to restore the previous outline thickness, by adjusting the `Outline Threshold` parameter through adding a `/4` to make the threshold 4 times smaller.
|
||||
* **Linear color space:** Previously Slot colors were not displayed the same in Unity as in the Spine Editor. This is now fixed at all shaders, including URP and LWRP shaders. See section *Additions* below for more details. If you have tweaked Slot colors to look correct in `Linear` color space in Unity but incorrect in Spine, you might want to adjust the tweaked colors. Slot colors displayed in Unity should now match colors displayed in the Spine Editor when configured to display as `Linear` color space in the Spine Editor Settings.
|
||||
* Additive Slots have always been lit before they were written to the target buffer. Now all lit shaders provide an additional parameter `Light Affects Additive` which defaults to `false`, as it is the more intuitive default value. You can enable the old behaviour by setting this parameter to `true`.
|
||||
* `SkeletonGraphic` now no longer uses a `RawImage` component at each submesh renderer GameObject when `allowMultipleCanvasRenderers` is true. Instead, a new custom component `SkeletonSubmeshGraphic` is used which is more resource friendly. Replacement of these components will be performed automatically through editor scripting, saving scenes or prefabs will persist the upgrade.
|
||||
|
||||
* **Additions**
|
||||
* Additional **Fix Draw Order** parameter at SkeletonRenderer, defaults to `disabled` (previous behaviour).
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8459fe8c08b88a84484f2b7ba5f36517
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,47 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Spine.Unity {
|
||||
|
||||
/// <summary>
|
||||
/// A minimal MaskableGraphic subclass for rendering multiple submeshes
|
||||
/// at a <see cref="SkeletonGraphic"/>.
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(CanvasRenderer))]
|
||||
public class SkeletonSubmeshGraphic : MaskableGraphic {
|
||||
public override void SetMaterialDirty () {}
|
||||
public override void SetVerticesDirty () {}
|
||||
protected override void OnPopulateMesh (VertexHelper vh) {
|
||||
vh.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: deeb12332c062954093c24a3fab10b83
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -72,7 +72,7 @@ namespace Spine.Unity {
|
||||
public bool unscaledTime;
|
||||
public bool allowMultipleCanvasRenderers = false;
|
||||
public List<CanvasRenderer> canvasRenderers = new List<CanvasRenderer>();
|
||||
protected List<RawImage> rawImages = new List<RawImage>();
|
||||
protected List<SkeletonSubmeshGraphic> submeshGraphics = new List<SkeletonSubmeshGraphic>();
|
||||
protected int usedRenderersCount = 0;
|
||||
|
||||
// Submesh Separation
|
||||
@ -203,7 +203,7 @@ namespace Spine.Unity {
|
||||
|
||||
base.Awake ();
|
||||
updateMode = updateWhenInvisible;
|
||||
SyncRawImagesWithCanvasRenderers();
|
||||
SyncSubmeshGraphicsWithCanvasRenderers();
|
||||
if (!this.IsValid) {
|
||||
#if UNITY_EDITOR
|
||||
// workaround for special import case of open scene where OnValidate and Awake are
|
||||
@ -262,16 +262,21 @@ namespace Spine.Unity {
|
||||
ApplyAnimation();
|
||||
}
|
||||
|
||||
protected void SyncRawImagesWithCanvasRenderers () {
|
||||
rawImages.Clear();
|
||||
protected void SyncSubmeshGraphicsWithCanvasRenderers () {
|
||||
submeshGraphics.Clear();
|
||||
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying)
|
||||
DestroyOldRawImages();
|
||||
#endif
|
||||
foreach (var canvasRenderer in canvasRenderers) {
|
||||
var rawImage = canvasRenderer.GetComponent<RawImage>();
|
||||
if (rawImage == null) {
|
||||
rawImage = canvasRenderer.gameObject.AddComponent<RawImage>();
|
||||
rawImage.maskable = this.maskable;
|
||||
rawImage.raycastTarget = false;
|
||||
var submeshGraphic = canvasRenderer.GetComponent<SkeletonSubmeshGraphic>();
|
||||
if (submeshGraphic == null) {
|
||||
submeshGraphic = canvasRenderer.gameObject.AddComponent<SkeletonSubmeshGraphic>();
|
||||
submeshGraphic.maskable = this.maskable;
|
||||
submeshGraphic.raycastTarget = false;
|
||||
}
|
||||
rawImages.Add(rawImage);
|
||||
submeshGraphics.Add(submeshGraphic);
|
||||
}
|
||||
}
|
||||
|
||||
@ -481,7 +486,7 @@ namespace Spine.Unity {
|
||||
}
|
||||
}
|
||||
canvasRenderers = newList;
|
||||
SyncRawImagesWithCanvasRenderers();
|
||||
SyncSubmeshGraphicsWithCanvasRenderers();
|
||||
}
|
||||
|
||||
public void Initialize (bool overwrite) {
|
||||
@ -660,7 +665,6 @@ namespace Spine.Unity {
|
||||
var canvasRenderer = canvasRenderers[i];
|
||||
if (i >= usedRenderersCount) {
|
||||
canvasRenderer.gameObject.SetActive(true);
|
||||
rawImages[i].Rebuild(CanvasUpdate.PreRender);
|
||||
}
|
||||
canvasRenderer.SetMesh(targetMesh);
|
||||
canvasRenderer.materialCount = 1;
|
||||
@ -704,10 +708,10 @@ namespace Spine.Unity {
|
||||
go.transform.localPosition = Vector3.zero;
|
||||
var canvasRenderer = go.AddComponent<CanvasRenderer>();
|
||||
canvasRenderers.Add(canvasRenderer);
|
||||
var rawImage = go.AddComponent<RawImage>();
|
||||
rawImage.maskable = this.maskable;
|
||||
rawImage.raycastTarget = false;
|
||||
rawImages.Add(rawImage);
|
||||
var submeshGraphic = go.AddComponent<SkeletonSubmeshGraphic>();
|
||||
submeshGraphic.maskable = this.maskable;
|
||||
submeshGraphic.raycastTarget = false;
|
||||
submeshGraphics.Add(submeshGraphic);
|
||||
}
|
||||
}
|
||||
|
||||
@ -731,7 +735,16 @@ namespace Spine.Unity {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
private void DestroyOldRawImages () {
|
||||
foreach (var canvasRenderer in canvasRenderers) {
|
||||
var oldRawImage = canvasRenderer.GetComponent<RawImage>();
|
||||
if (oldRawImage != null) {
|
||||
DestroyImmediate(oldRawImage);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
protected void EnsureMeshesCount (int targetCount) {
|
||||
int oldCount = meshes.Count;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user