Tim Cooley
Tim Cooley

Reputation: 759

How to enable and disable an EmptyGameObject in unity?

How do I disable and enable an EmptyGameObject?

I nested two animations from Spine in this empty game object and want to turn off the whole thing but be able to turn in back on.

I was using SetActive, but that killed the thing and made it so it wouldn't come back.

Upvotes: 0

Views: 593

Answers (1)

Salvador Lemus
Salvador Lemus

Reputation: 146

You're right at using SetActive but you need to call that function outside of your GameObject, otherwise it wouldn't be able to activate again because the script will be disabled too.

So, put a Script in another GameObject A that will be active the whole time, make a public variable to store a reference from your GameObject B with animations and call SetActive from A to Activate/Deactivate B.

Upvotes: 2

Related Questions