Hi, i’m simply trying to create a class with parameters, such as a gameobject name etc…
and bring them over to my ‘zone’ script. but I get the empty prefab error.
I understand that it’s not running the awake function in my ‘buildSphere’ first, so it’s not being set. How would I go about running that? I’ve tried instancing the buildSphere script > making the gameobject non static, but then I come into some monobehaviour problems. Stuck with this.
Any help would be greatly appreciated!
buildSphere:
public static GameObject zoneTowerObj;
public static int strength = 15;
public static string towerName = "Awesome build sphere";
public static int minHealth = 0;
public static int currHealth = 90;
public static int maxHealth = 100;
void Awake(){
if (!zoneTowerObj) {
zoneTowerObj = Resources.Load ("buildSphere") as GameObject;
} else {
}
}
Zone Script:
if (!zoneTower) {
if (GUI.Button (new Rect (10, 300, 100, 20), "Add Tower")) {
dir = transform.position;
zoneTower = buildSphere.zoneTowerObj;
zoneTowerName = buildSphere.towerName;
zoneTowerStength = buildSphere.strength;
zoneTowerMinHealth = buildSphere.minHealth;
zoneTowerMaxHealth = buildSphere.maxHealth;
zoneTowerCurrHealth = buildSphere.currHealth;
Instantiate (zoneTower, dir, Quaternion.identity);
zoneTower.name = zoneTowerName;
}
}