void Start()
{
thisComp = this.GetComponent<Toggle>();
thisComp.onValueChanged.AddListener(delegate{SelectShape(thisComp);
});
}
void Update()
{
}
public void SelectShape(Toggle value)
{
nameOfObject = this.name;
selectedObj = GameObject.Find(this.name);
chooseDropDown = GameObject.FindWithTag("dropdown");
chooseOptions = chooseDropDown.GetComponent<Dropdown>();
if (chooseDropDown = GameObject.Find(nameOfObject))
{
if (chooseOptions.options[chooseOptions.value].text == "Resize Shapes")
{
if (value.isOn)
{
Instantiate(cube);
selectedObj.tag = ("selected");
}
if (!value.isOn)
{
Instantiate(cylinder);
selectedObj.tag = ("shapes");
}
}
}
}
For some reason, when the toggle is on, the object switches tag to “selected”. But when the toggle is off, it does not go back to “shapes”. Any idea what I’m doing wrong?