Page 1 of 1

Unity: Best way to access parent NoesisView from xaml code behind?

Posted: 11 Mar 2018, 19:33
by antsonthetree
Hello,

Currently I am getting access to the parent NoesisView from xaml code behind this way:
NoesisView nv = GameObject.FindWithTag("GUICamera").GetComponent<NoesisView>();

But that requires me to always know the game object (GUICamera) the view is attached to.
Is there a better way to find this from a UserControl's code behind?

Thanks
Jake

Re: Unity: Best way to access parent NoesisView from xaml code behind?

Posted: 12 Mar 2018, 18:28
by sfernandez
Hi,

There is no access method to get that information right now.
Could you please create a ticket in our bugtracker and we will analyze the best way to provide that info?

Meanwhile, you can look for all the NoesisView active components in the scene using Unity's FindObjectsOfType, and then compare VisualTreeHelper.GetRoot(NoesisView.Content) with you user control root (VisualTreeHelper.GetRoot(this)). Please note that this would be very slow, so it wouldn't be recommended to use it every frame.