I have two scripts - an inventory script attached to my player and an item database (which is giving me trouble). The database stores icons and models. I want to be able to instantiate the database object in my inventory script and pull up icons and models from the instance. How do I go about this?
The problem is that instantiating the database with a constructor seems to circumvent the Start() method and the public fields of the script I fill in the editor. So I end up with all my images and models being null. I could have the database build itself when the constructor is called but dragged-in references to my files don’t seem to stick with the instance and also end up being null when I hit play. I tried using Resources.Load
in my constructor and even though everything worked Unity threw angry errors about main threads and Load calls - I’d like to avoid those if I could.
So what is the right way of doing this?