I have a component (call it Foo) that I attach to all instances of a certain type of object in my scene. This is done manually via the editor interface, and that’s sufficient for my needs.
Foo.Start() adds a new component to its gameObject - let’s call this component Bar.
Every instance of Bar needs to be able to instantiate a prefab (the same prefab for all instances of Bar). Ideally I would not have to explicitly reference this prefab in the inspector view of every Foo object just so that reference can be passed on to the Bar component that Foo.Start() creates.
My first attempt to solve this problem was to set a “default reference” (as seen in the Inspector when looking at my Bar script asset) - this did not result in the property automatically taking on the appropriate prefab reference once a Bar was created at runtime. Fair enough, I assume my understanding of default references is incomplete.
For a second attempt, I thought perhaps I could just create a singular component with a public static reference to the prefab so that Bar scripts could directly refer to that reference. Unfortunately static members are not displayed in the Inspector and thus (to my knowledge) cannot be bound to prefabs in any way.
It is also worth noting that although this example is distilled down to a simple requirement, the reality is that each Bar needs to be able to instantiate around ~5 prefabs (the same 5 for each instance of Bar) as well as they each need to play multiple AudioClips. The same problem of course arises in trying to reference AudioClips this way.
Surely there’s a better way to tackle this problem. Any suggestions would be greatly appreciated!