Replacing "Storage" with Singleton Instance

December 1, 2018

Every time I used to want to acces a single-use gameobject (like GameController or CamerController) I would write a function in the Storage class that would do a "GameObject.Find()" function and return the object's script. This has been replaced with a Singleton ("public static scr_GameController Instance", for example) and assign the script as the Instance in the Awake() function. This Instance can then be called using scr_GameController.Instance… in place of Storage.GameController()… . Doesn't save in lines of code or characters, but hopefully the lack of a tag-based Find() will improve speed. Also it simplifies the lookup a bit.

Share on Facebook
Share on Twitter
Please reload

Uitgelichte berichten

I'm busy working on my blog posts. Watch this space!

Please reload

Recente berichten

October 26, 2018

October 25, 2018

October 23, 2018

May 30, 2018

Please reload

Archief
Please reload

Zoeken op tags

I'm busy working on my blog posts. Watch this space!

Please reload

Volg ons
  • Facebook Basic Square
  • Twitter Basic Square
  • Google+ Basic Square