Showing posts from 2017

Service Locator design pattern for unity3D

Hi everyone, When working with unity and especially as the number of your scripts gets better, you start getting a lot of dependencies between scripts and you found the need to reference other scripts. For example you have game manager for you global settings , and you find the need that your enemies script and audio manager and camera and so on wants to get reference to your game manager. Ofcourse with unity it's easy , just make a public variable game manager and assign it in the editor but this might cause some problems over time: Mostly you will have a lot of public variables in your editor that it will get messy and you need to assign it correctly every scene. what if the script is on perfab that you generate at run time ?       you will need to get the script on the instantiated game object and assign the variable to it in runtime. -------------------------------- What if there's away to ease this process abit and lower our code coupling! And actual