Optimizing Unity UI

Unity recently posted a guide to optimizing the Unity UI:

Optimizing Unity UI

https://unity3d.com/learn/tutorials/topics/best-practices/guide-optimizing-unity-ui

I was very eager to read it, because up until now there hasn’t been much information about those topics. I look forward to more of this kind of information being included in the manual, but until then it’s great that this has been made available.

It came at a really opportune time, as I was starting to optimize my UI, but I had so many questions that weren’t answered in the manual or the forums. Luckily some of those questions, and probably the most important ones, were answered in those posts. Yay!

One of the things I’ve struggled with is keeping draw calls low. I have a complex UI with many moving parts, and at times it’s had a ridiculous number of draw calls. As I’m still adding functionality, I haven’t properly begun the process of optimization yet. That will come as I replace the placeholder graphics with final graphics. But there are many things I could have done to make the UI more efficient from the beginning.

If you’re just starting out, some of the information in Unity’s guide may go over your head. But there are some real gems in there which can help to make UI creation much more efficient, and definitely increase performance. Here are some of the things I learned:

Continue reading “Optimizing Unity UI”

Optimizing Unity UI

Unity uGui Button Long Press

ButtonLongPress

I’ve been spending a fair bit of time with Unity’s UGUI for my latest project. Having wrestled with it for a while, in some ways I wish I’d stuck with NGUI, but I’ve learned a lot along the way so it’s not all bad.

In my UI I have some buttons which open sub menus, but I wanted to be able to rename the menu item as well. Since the target is mobile, right click is out. I thought a long press would be an intuitive way for users to change the name, so I had a quick look to see if anyone had already done this.

I came across this Unity forum post which has a script/component that works quite nicely.

The thing is, I’ve been avoiding including any Update() methods in my UI to keep it as speedy as possible, so I rewrote that long press script to avoid Update() and it’s turned out to be a fair bit quicker as well:

Continue reading “Unity uGui Button Long Press”

Unity uGui Button Long Press