- Home /
ISelectHandler, IDeselectHandler With children elements
I have an object that on selecting that object will show additional hidden elements. When the focus is removed from this element I want its interface to disappear.
public void Start() {
recycleButton = transform.Find ("Recycle").gameObject;
Hidden (recycleButton.GetComponent<Button> (), true);
recycleButton.GetComponent<Button> ().onClick.AddListener (GoToLoot);
}
public void OnSelect (BaseEventData eventData)
{
if (showRecycle && !isSelected) {
Hidden (recycleButton.GetComponent<Button> (), false);
isSelected = true;
}
}
public void OnDeselect (BaseEventData eventData)
{
if (showRecycle) {
Hidden (recycleButton.GetComponent<Button> (), true);
isSelected = false;
}
}
public void GoToLoot() {
SceneManager.LoadScene ("Loot");
}
The OnSelect, and Deselect are firing. However if I have hidden called to hide the button it won't redirect to the next scene. Also I tried just using SetActive instead of the hidden function. Why won't GoToLoot fire when hiding gaming objects on the screen?
So if I delay the hiding of the button by about 400 mili seconds it works. However I would prefer to not do this.
I ended up just refactoring everything and didn't use the OnSelect OnDeselect. I made a method that got all the items that had the recycleButton and onSelected hided all of them.
Your answer
![](https://koobas.hobune.stream/wayback/20220612112530im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Is there still have the old UI color theme in Unity 3 Pro? 2 Answers
Flash inside Unity 3 Answers
command system with 3d gui interface 0 Answers
Character Interface Change (Help) 0 Answers