Sign in

SCILLCameraOffset

class SCILLCameraOffset : MonoBehaviour

Overview

In many UIs for challenges and battle passes you will want to render 3d models on the left or right side of the screen. This is also often the case for inventory and many other things. One solution to that is to create another camera, rendering to a render texture and using a RawImage element in the UI. However, we think the better approach is just to render a scene with a camera placing objects on the left or right.

However, there is one caveat: perspective distortion. This looks like this:

This looks ugly

This looks ugly

The solution to this is to change the projection matrix of the camera to offset the center of the screen. You can attach this script to your camera rendering the reward and change the Offset to adjust the objects position on the screen.

Please note, the object should be in line with the camera (i.e. should have the same X value as the camera) to prevent perspective distortion.

This looks like this:

This looks ugly

This looks ugly

Please excuse the ugly looking battle pass. This style is used for customization as it’s very easy to see the the different modules to drag them to a new position and to update sprite images and the design. It’s a good starting point if you want to layout your battle pass UI without starting from scratch.

Inspector Properties

xOffset

public float xOffset = 0.0F;

Sets the offset of the X-axis (left or right) to shift the perspective center to the left or right. Play around with this value it will be directly visible in the Unity Editor.

YOffset

public float YOffset = 0.0F;

Sets the offset of the Y-axis (up or down) to shift the perspective center to the left or right. Play around with this value it will be directly visible in the Unity Editor.