I am trying to make a simple tower defense game, I am now working at creating the “shop”. To place a tower I need to check its price (it is set in a prefab) before I allow player to drag the tower. How do I check prefab property, price, before instantiating it? I can set the price by just changing button a bit, but everytime I’d change the price of a tower in the future, I’d have to change many variables instead of one. I am writing in C#.
Not sure what the problem is. Access them the same as any other variable on a GameObject
public GameObject myPrefab
void Start (){
myPrefab.GetComponent<MyComponent>().myPublicVariable = 17;
}