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