From b3f76c4e54200e0cfc497248eb1fd1b1e826d691 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Wed, 23 Jun 2021 20:30:33 +0200 Subject: [PATCH] [unity] Fixed SkeletonGraphic `Update When Invisible` not working. Now it uses `onCullStateChanged`, which can be used with RectMask2D. Closes #1910. --- .../Runtime/spine-unity/Components/SkeletonGraphic.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs index ae16f2ed3..366054a6e 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs @@ -202,7 +202,8 @@ namespace Spine.Unity { protected override void Awake () { base.Awake (); - updateMode = updateWhenInvisible; + this.onCullStateChanged.AddListener(OnCullStateChanged); + SyncRawImagesWithCanvasRenderers(); if (!this.IsValid) { #if UNITY_EDITOR @@ -313,6 +314,13 @@ namespace Spine.Unity { UpdateMesh(); } + protected void OnCullStateChanged (bool culled) { + if (culled) + OnBecameInvisible(); + else + OnBecameVisible(); + } + public void OnBecameVisible () { updateMode = UpdateMode.FullUpdate; }