UI Parallax Libary by RodionLodza - 2

Shaders & EffectsGUI

Library of scripts for creating the parallax effect on UI elements in Unity.

Unity 2019.1.5f1MIT LicenseUpdated 93 days agoCreated on February 22nd, 2020
Go to source

UIParallaxLibary

Library of scripts for creating the parallax effect on UI elements in Unity.

Watch on GitHub Star on GitHub
<< How does it work | How to use | Install | Download >>

What does it look like

0

How does it work

UI elements are usually displayed orthogonally, so it is impossible to create a parallax effect by moving and rotating the camera. However, no one is stopping us from moving and rotating UI objects in such a way as if the camera were moving, not the objects. Such a movement of UI objects gives a very realistic parallax effect.

The library uses an accelerometer, not a gyroscope, because an accelerometer is present on more devices than a gyroscope.

0 0

How to use this library

First, you need to place the main component of the parallax effect on the scene - the UIParallaxEffect script. It contains a set of UIParallaxLayer objects, which is an array of different UI elements with its parallax settings.

Important! UIParallaxEffect must be initialized and updated in the Start and Update methods (for this you can implement your own UIParallaxManager controller class (see the example in the project), or through any other controller).

0

Secondly, you must define each UIParallaxLayer in the UIParallaxEffect component. UIParallaxLayer has several parameters that will be described below.

0

Parameters UIParallaxLayer

  • ParallaxLayerName - layer name (for ease of display)
  • ObjectsRect - array of RectTransform objects that belong to this layer
  • PosXMultiplier - the value at which the X position in the anchoredPosition of the objects changes
  • PosYMultiplier - the value at which the Y position in the anchoredPosition of the objects changes
  • InterpolationSpeed - parallax speed, in other words, the speed at which layer objects move and rotate

How to install?

  1. Download UIParallaxEffect.unitypackage and using UnityPackageManager.
  2. The Unity Package Manager (UPM) is a new method to manage external packages. It keeps package contents separate from your main project files.

Modify your project’s Packages/manifest.json file adding this line: "com.lodza.uiparallax": "https://github.com/RodionLodza/UIParallaxLibary.git#package-branch"

To access classes inside of this package you will need to add a reference to com.lodza.fastpool.asmdef to your project’s assembly definition file.

License

Show all projects by RodionLodza