Let's say I have three scripts, each attached to three separate game objects.
In one script I am loading up some data from text files, and that data needs to be available to the other two scripts, as they need use of it in their Start() functions.
Based on the Debug.Log lines I have printed out from each of the scripts, it appears that Unity just sort of arbitrarily loads everything as it feels like it. How can I set the order of script priority so that a certain script ALWAYS loads and finishes before any other scripts in the project do?
Use Awake() to initialize stuff that has to be done before Start(). If you need more than two levels of ordering, then you have to implement some kind of routine on a game manager object that calls functions on other scripts in your defined order.
Under (Default Time) click on the Plus(+) Sign on the bottom right to add the Script(GameManager Script) that should run before any other Script. The script name doesn’t matter, just the concept of which Script you want to run before another. that being said if the script works do not follow these steps at all, your code is fine as is. Only use it if your script is interfering with time order of another Script from performing properly. Which is usually the GameManager and AudioManager I’ve only came across.
This is what helped my music to start playing again because my GameManager Script and AudioManager Script was loading(running) at the same or wrong time which I guess caused it not to recognize the AudioManager.instance I wrote to the GameManager. Hope this helps you as it did me, Cheers!