Hey! So I am trying to make a Building Placement script where you place a building by pressing a button and it lets you place it. But for some reason its not moving at all. If you need anything ask me and my code is below
using UnityEngine;
using UnityEngine.UI;
public class GUIScript : MonoBehaviour {
BuildManager bm;
Button house, tower;
bool buildopen = false;
// Use this for initialization
void Start () {
bm = GameObject.Find("BuildManager").GetComponent<BuildManager>();
Canvas cv = GameObject.Find("Canvas").GetComponent<Canvas>();
house = cv.transform.FindChild("HouseButton").gameObject.GetComponent<Button>();
tower = cv.transform.FindChild("TowerButton").gameObject.GetComponent<Button>();
}
public void ActiveteBuilding(Button pressedBtn)
{
if (pressedBtn.name == "BuildButton")
{
if (buildopen)
{
//bm.DeactivateBuildingmode();
house.gameObject.SetActive(false);
tower.gameObject.SetActive(false);
pressedBtn.image.color = Color.white;
buildopen = false;
}
else
{
//bm.ActivateBuildingmode();
house.gameObject.SetActive(true);
tower.gameObject.SetActive(true);
pressedBtn.image.color = new Color(255, 0, 255);
buildopen = true;
}
}
else
{
switch (pressedBtn.name)
{
case "HouseButton":
bm.SelectBuilding(0);
break;
case "TowerButton":
bm.SelectBuilding(1);
break;
}
pressedBtn.image.color = new Color(155, 120, 255);
bm.ActivateBuildingmode();
}
}
void Update()
{
if (buildopen)
{
if (!bm.isBuildingEnabled)
{
if (house.image.color != Color.white)
house.image.color = Color.white;
if (tower.image.color != Color.white)
tower.image.color = Color.white;
}
}
}
}