I want to access a script I have attached to a prefab to get some public values from it. I am creating several prefabs that all use the same script, but with different values (to assign resource costs to placeable buildings).
I want to access these values from a script I have attached to a UI button to see if I should enable the button (the button will spawn a structure for placement by the player). If they have the resources, then instantiate. I want to avoid instantiating first though since the entire idea is to see if I should instantiate in the first place.
Is there a way to do this? Is there a better design pattern I should perhaps be investigating? I’m using C# btw.
EDIT: What I ended up doing is creating a single class that acts as a list of each building I have available. Each building is instantiated once in this list as a gameobject on load of the game. In that way, I can reference the scripts contained in them. also allows me to quickly clone them without loading the prefab constantly.