Handle gameover through prefab

Updated on July 18, 2018 in [A] Unity Scripting
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
3 on July 12, 2018

I have prefabs with scripts and non prefabs with scripts.

 

I want to control both when the game is over.

 

I am storing gameover=true in another script which is in an empty game object.

 

How would I tell the game is over to prefabs

  • Liked by
Reply
0 on July 12, 2018

Just make gameover static. Then other scripts can access it with:

nameofgameoverclass.gameover;

 

  • Liked by
Reply
Cancel
1 on July 14, 2018

but we can’t access it through prefab scripts.. am I right??

on July 18, 2018

You can access static elements anywhere.

 

Show more replies
  • Liked by
Reply
Cancel