/// <summary> /// Handles selection state for this item, but this method gets called on other radio buttons within the same group too. /// Called by selectButton's Toggle component. /// </summary> public void IsSelected(bool thisSelect) { //if this object has been selected if (thisSelect) { //tell our ShopManager to change the database entry ShopManager.SetToSelected(this); //if we have a deselect button or a 'selected' gameobject, show them //and hide the select button for ignoring further selections if (deselectButton) { deselectButton.SetActive(true); } if (selected) { selected.SetActive(true); } Toggle toggle = selectButton.GetComponent <Toggle>(); if (toggle.group) { //hacky way to deselect all other toggles, even deactivated ones //(toggles on deactivated gameobjects do not receive onValueChanged events) IAPItem[] others = toggle.group.GetComponentsInChildren <IAPItem>(true); for (int i = 0; i < others.Length; i++) { if (others[i].selCheck.isOn && others[i] != this) { others[i].IsSelected(false); break; } } } toggle.isOn = true; selectButton.SetActive(false); } else { //if another object has been selected, show the //select button for this item and hide the 'selected' state if (!deselectButton) { selectButton.SetActive(true); } if (selected) { selected.SetActive(false); } } }