Wonky UI

Nothing has killed my passion for Unity like this section. NOTHING behaves properly with this UI. My whole panel decides to resize itself after about every 3rd thing I do. Completely garbling everything. Most of the time my text components of the headers refuse to resize with the header rects despite being on stretch. I’ve fought this for an hour. Absolutely no fun. I really regret hitting the prefab variant option like he advised, as well. He commented “oh in case you want to make a change across the board.” Yeah, well… only ONE of the panels is even connected. The rest are their own thing with the way we set this up anyway.

I really do enjoy UI work typically. It’s fun and a place to really set yourself apart. But I just don’t get why Unity is being so terrible with this. And I am using 2021. I fear I am going to skip the rest of this section and download the commit and go right to abilities. That is what I want to learn more of. But I really am interested in how the back end of the shop system works. The UI is just… putrid and it really frightens me for when I am ready to make my own project(especially considering I will be doing a VR project. Though the VR sandbox I made had some simple UI that worked just fine back in 2019).

Not sure what my point was. If anyone can talk me off the ledge it’d be nice though. Any tips or things I might be whiffing on would be appreciated. Just really not feeling it tonight.

Customary EDIT: I have grabbed the commit after the initial shop UI setup. I really will miss my changes and my extensive commenting I had done… I suppose I can always redo all that later. I just couldn’t take it any more and really still want to learn more. I am hoping the Better UI asset tool that I got in that bundle helps with some of the wonkiness. I am just amazed that I wasn’t seeing these same quirks when he was making the UI in general.

Eidt 2: That didn’t even seem to work right, actually. Blew up my changes since the start of this course(but since I made the prefabs for the component section those are still there) and will try again when I am not so irritable. Sigh.

Last Edit: I was able to combine things. Tediously. I got the commit. It seemed to be working when I just deleted my whole UI folder and then copied in the one from the commit. However, when I went to edit anything I’d get errors about missing scripts. I tried exporting properly from the commit with a unity package but the same thing happens. Apparently Unity won’t just look for a script by name. So I had to manually go add each script and then hook all of their Serialized Fields back up. BUT… It works. I now have my project/scripts/customizations with Sam’s UI in place.

Also, sorry if this was a grumpy/whiny post. I just can’t comprehend what Unity was doing to my poor UI whenever I would try to do anything. Just if anyone out there is feeling this, know you are not alone… And if anyone has any pointers to make things smoother, point away. <3

1 Like

Unfortunately, Unity serializes script references by UUID instead of a script name… that being said, when you rename a script, since Unity has serialized the references by UUID you usually don’t lose the reference. But… when you delete a script and replace it, Unity’s references break.

This experience is more common than you might think. I’m sorry it’s been difficult, and what Sam doesn’t mention in the videos is the multiple number of takes needed just to get things to work. This single issue is why we strongly recommend unchecking the Automatic Save in Prefab mode. Even then, a save can cause cascading failures up the chain of prefabs. For this, regularly committing your project to source control is essential. Quite literally, before even beginning to mess with UI, commit. Every succesful change, commit. Every time it breaks, roll back. With short incremental commits, you can nullify Unity’s UI system’s tendency to break.

Unfortunately, despite Unity knowing how easy it is to break UI with a simple edit (undo just doesn’t seem to work once the UI gets reversed in on itself), they’ve put all of their UI department resources over the last two years into the UIElements sytem. At some point, I will be releasing a tutorial on doing a wholesale conversion of the UI in the RPG game to UIElements.

1 Like

Thank you for this. It helps me keep what little sanity the mighty Lord Cthulhu hasn’t already sapped from me.

Yeah I am going to commit a lot more often, to keep from getting committed myself… see what I did there?

Someone necro-liked this post so I figured I’d revisit this real quick for posterity.

Again, sorry I sounded like an infuriated toddler in the OP.

But I have learned the biggest part of all the wonkiness is nested prefabs. What can happen, randomly at Unity’s will, is that if you are editing at a prefab level and that prefab is in another prefab(which, let’s face it… could ALSO be in a big main UI prefab) the parent prefabs can “remember” the old configuration and send it up the chain.

For example. You make a small adjustment to positioning in an indicator window containing buff icons in prefab edit mode. Looks perfect! Good job! Then when you get out of the prefab and see your UI as a whole you notice that the positioning has reverted. You go back and do it again. Get out and NOPE… still. Then you go to the prefab level for the area of the UI or category you placed that indicator panel in and see that the old position is there as well. Usually you can hit revert for that area of the UI and it will then start behaving. (And yes, this is a specific situation that just happened to me and I kept my cool this time :rofl:)

2 Likes

Privacy & Terms