How Can I make a prefab refrence a non prefab object without the prefab being in the scene

Let me try to explain:
In my game, I am having players find “fairy” allies to help them in the game. I have a counter that I want to display how many of each kind of fairy you own. I want 1 fairy of each fairy out at a time, and when a fairy of a type dies, I want it to spawn in another fairy of that type IF you have enough. At the beginning of a level, I want it to spawn in 1 of each fairy if you have them. I have a game object managing the score display and the fairies themselves are prefabs. My struggle is that the fairy script has to refrence the manager for certain things, but when instantiating it, it has no refrenece. And turning the refrence itself into a prefab doesnt work, becuase when I assigned the refrence in the fairy prefabs, they would refrence the prefab manager instead of the copy of the manager actually in the scene. I have spent 2 hours on this system and cant seem to get it to work. Is there a way to refrence the non prefab in the prefab objects, or a different system that will produce a similar effect?

I found a way! Turns out you can set refrences thru code. Who knew lol

1 Like