spine-unity-docs icon indicating copy to clipboard operation
spine-unity-docs copied to clipboard

OnValidate: unassigned components

Open iggyzuk opened this issue 4 years ago • 0 comments

http://en.esotericsoftware.com/spine-unity-events

In the HandleEventWithAudioExample values aren't assigned to anything.

void OnValidate () {
    if (skeletonAnimation == null) GetComponent<SkeletonAnimation>();
    if (audioSource == null) GetComponent<AudioSource>();
}

It should be:

void OnValidate() {
    if (skeletonAnimation == null) skeletonAnimation = GetComponent<SkeletonAnimation>();
    if (audioSource == null) audioSource = GetComponent<AudioSource>();
}

I've made this mistake many times before.

iggyzuk avatar Jan 01 '21 09:01 iggyzuk