Shavik
Topic Author
Posts: 3
Joined: 12 May 2014, 22:37

FindName returning null

12 May 2014, 22:46

I will post a paste bin of my C# and XAML in their entirety below. (Please disregard style and such as this was supposed to be a quick demo of C# <-> XAML.)

I'm running into an issue assigning a control via the FindName method.

I saw two examples from sfernandez on the unity forums from last year.
http://forum.unity3d.com/threads/192064 ... ASED/page8

I have a pretty simple Grid -> Two Stack panels of Textblocks defined via XAML that I created with Blend for VS 2013.

I am able to get FindName to return the stackpanels and if I iterate over the children of the stack panels I see that they have the correct number of children but each child's GetName method returns an empty string which I assume has something to do with the FindName not finding it. A colleague of mine tried this and was successful.
The only work around I've found is to select the controls via a hard set GetChildren.Get(i) which is obviously not a long term solution.

Is it possible that this is due to the fact I'm using the Unity Trial? Everything else so far seems to work so I'd find it strange this small method would not function due to my trial status. I have fully purchased NoesisGUI on the asset store during the Madness sale and I am aware that I will have to purchase Unity Pro after my trial to continue using NoesisGUI.

Thanks for any and all help!

Attached Code Below
XAML: http://pastebin.com/hY706fEs
C#: http://pastebin.com/KSd98LEp
* Note: The code includes some extra fluff and other things I tried to get it working so the "current state" has diverged from the example provided in the aforementioned link.

Additional question: Should I be using a UserControl for this? When is the ideal time to use a UserControl over the way I've done it here? Example cases?
Last edited by Shavik on 12 May 2014, 23:06, edited 1 time in total.
 
Shavik
Topic Author
Posts: 3
Joined: 12 May 2014, 22:37

Re: FindName returning null

12 May 2014, 23:06

Well after spending around 5 hours yesterday troubleshooting it, I think I've just fixed this on my own.

I was reading another post and the suggestion for an entirely unrelated issue was to go to the NoesisGUI settings and rebuild it.

I did that and it is successfully finding the controls now.

Hopefully this can help anyone else that may be having the same or similar issue.
 
wckdspn
Posts: 67
Joined: 18 Aug 2012, 23:14

Re: FindName returning null

12 May 2014, 23:22

If you edit and save a file while in play mode of the editor, it will fail to compile it. So changes can be missed if you do that. You can always build manually, so it's more of a minor annoyance. It would be nice if it could track files that changed while it was unable to overwrite them to process when it could. Not quite sure how to go about that. Might need some support from Unity's side.
 
User avatar
sfernandez
Site Admin
Posts: 1912
Joined: 22 Dec 2011, 19:20

Re: FindName returning null

13 May 2014, 09:22

If you edit and save a file while in play mode of the editor, it will fail to compile it. So changes can be missed if you do that. You can always build manually, so it's more of a minor annoyance. It would be nice if it could track files that changed while it was unable to overwrite them to process when it could. Not quite sure how to go about that. Might need some support from Unity's side.
This is something we will try to improve for next version. If something changes during play, we have to detect it and automatically build it when editor stops.
 
Shavik
Topic Author
Posts: 3
Joined: 12 May 2014, 22:37

Re: FindName returning null

13 May 2014, 18:38

I do want to state that this was not an issue of being in Play mode while editing. This persisted through Unity/Blend restarts and even full system restarts. It required a manual build.
 
User avatar
jsantos
Site Admin
Posts: 2904
Joined: 20 Jan 2012, 17:18
Contact:

Re: FindName returning null

14 May 2014, 02:06

We have observed that sometimes Unity fails to notify us when a file changes. This also happens when installing the unity package. If this happens the best solution is saving again the XAML.

Anyway, this is far from ideal. We are considering the option of checking for changes ourselves (not relying in the notification sent by unity) each time the play button is pressed.
 
wckdspn
Posts: 67
Joined: 18 Aug 2012, 23:14

Re: FindName returning null

14 May 2014, 02:08

We are considering the option of checking for changes ourselves (not relying in the notification sent by unity) each time the play button is pressed.
If you do, make certain it's optional. I could see delaying play for the check to be potentially irritating for someone not immediately working on UI.
 
User avatar
jsantos
Site Admin
Posts: 2904
Joined: 20 Jan 2012, 17:18
Contact:

Re: FindName returning null

14 May 2014, 02:15

It would be an incremental build. They are very fast. But yes, we need to take care with this decision.

Who is online

Users browsing this forum: No registered users and 1 guest