Created
January 9, 2020 16:43
-
-
Save FNGgames/c355e37c65ad70d4d6c3e78500407487 to your computer and use it in GitHub Desktop.
Spine Frustrum Culling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Spine.Unity; | |
using UnityEngine; | |
[RequireComponent(typeof(Renderer), typeof(SkeletonAnimation))] | |
public class SpineFrustrumCullSkeletonAnimation : MonoBehaviour | |
{ | |
private SkeletonAnimation _anim; | |
private Renderer _renderer; | |
void Start() | |
{ | |
_anim = GetComponent<SkeletonAnimation>(); | |
_anim.enabled = GetComponent<Renderer>().isVisible; | |
} | |
void OnBecameVisible() => _anim.enabled = true; | |
void OnBecameInvisible() => _anim.enabled = false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment