Creating A UI Parallax Effect In Unity

Want a simple detail to boost the quality of your UI for very little work? Try a parallax effect.

Vincent Taylor
Mar 24, 2022

Today’s Objective: Create a parallax effect for the UI of my Main Menu, which reacts to the mouse position.

The Existing Scene:

I currently have a Main Menu scene set up with a title, 2 buttons, and a background.

The background consists of 2 separate images: a blue sky, and a collection of buildings.

I want to add a parallax effect to the buildings so that they move slightly as the mouse moves, following its screen position.

The Code:

After creating a new class, I add some variables:

Now for the methods which create the effect:

The Result:

--

--

Vincent Taylor

Unity game developer / C# Programmer / Gamer. Australian (Tasmanian) indie games developer for 10+ years. Currently looking for games industry employment.