void OnButtonClick() { ObjectSpawnerTool objectSpawnerTool = toolGun.GetComponent <ObjectSpawnerTool> (); if (!objectSpawnerTool) { toolGun.AddComponent(typeof(ObjectSpawnerTool)); } objectSpawnerTool.objectPrefab = objectPrefab; if (fireToolGunOnTileClick) { objectSpawnerTool.FireToolGun(); } }
void Start() { gameObject.tag = "toolGun"; objectSpawnerTool = gameObject.GetComponent <ObjectSpawnerTool> (); }