Browse Source

[unity] Fixed SkeletonGraphic `Update When Invisible` not working. Now it uses `onCullStateChanged`, which can be used with RectMask2D. Closes #1910.

Harald Csaszar 4 years ago
parent
commit
b3f76c4e54

+ 9 - 1
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;
 		}