Unity UI Tips

Fanzhong Zeng
2 min readOct 16, 2020

--

This is my list that I believe is important when creating UI elements in Unity.

Organize using Empty gameObject.

Everything in the Unity UI can be organized inside an empty gameObject. UI elements that is similar should be grouped together under the same gameObject. Not only is this better for organization, it’s also useful when you want to turn certain elements on or off and making changes to them. Where instead of moving each UI element one by one, you can move the group and modify the group all at once.

Rect Transform Values

When moving and changing objects around, the position and width/height tend to end up with weird decimal numbers. Try to round up/down the numbers after you find a good location for them.

Place Pivot Points Later

When creating the UI, don’t worry about the pivot points at first. Figure out which elements need to exist where, and grouping them together first. After everything is done, then place the pivot points since that’ll be the finalized location.

Don’t mess with Scaling unless needed by animation or for UI Scaling settings.

UI Scaling should ideally limited to giving the user the ability to change the UI size, if the default scaling isn’t 1, you’ll have to do extra math just to figure out how to scale things down easily. The other option is to use it for certain animations where the UI scaling is only temporally changed and will revert back.

Disable Raycast Target for Non Interactive Elements

If the element is not an interactive object, disabling Raycast Target can improve performance since Graphic Raycaster will check every frame for all the elements that is marked as Raycast Target.

--

--