Hi,
I’m sort of new to using Unity’s UI systems and I am trying to create a UI pop-up template that I could load content into at runtime. I made a mistake thinking that EditorWindow was able to pop-up in-game so I made a demo pop-up (that can’t load content at runtime) version through EditorWindow first, but now I’m trying to transition to a “Canvas-Panel pop up”. For both I used an UXML template that has all the elements needed in place, then through script load in the text that I want to display onto the pop-up window.
However, when I do that, for some reason even the close button on the pop-up ceased to work, and none of the contents are loading in either. I am starting the debugging with fixing the button. Through using Debug.Log I could tell that the RegisterCallback is called, but the button clicks aren’t registered because the following methods aren’t called.
For the button, the code I am using looks like this
rootVisualElement.Query<Button>().ForEach(RegisterHandler);
private void RegisterHandler(Button btn){
Debug.Log("Handler added ");
btn.RegisterCallback<ClickEvent>(ClosePopUp);
}
private void ClosePopUp(ClickEvent e){
Debug.Log("Button clicked ");
this.gameObject.SetActive(false);
}
If you guys could let me know what I could do to try to fix the button and/or the content not loading in, or if there is a better way to do this, please let me know. Thanks ahead.