Home › Page › UghCamera

UghCamera

Inherits from MonoBehaviour

The UghCamera renders everything in the Ugh GUI_LAYER (by default, Unity layer 20.) It is an orthographic Camera that automatically resets its position to (0, 0, -10) pointing towards (0, 0, 0).

UghCamera is a smart object that will instantiate itself when needed.  (You should never have to manually add an UghCamera to a scene.)

Variables
name type description
Aspect float The aspect ratio of the UghCamera as rise over run.
CameraPixelSize Vector3 The x and y elements define the width and height of the screen in pixels.
guiLayer int Holds current layer value that the Camera will render.  See GUI_LAYER below.
ScreenExtents Vector3 The x and y elements define the half-width and half-height of the screen in Unity units.
ScreenSize Vector3 The x and y elements define the width and height of the screen in Unity units.
Functions
name type description
ScreenAnchorToPosition Vector3 Returns a position, in Unity units, that corresponds to an anchor location on the screen.
Class Variables
name type description
Instance UghCamera Returns the instance of the UghCamera in the scene, or null if none is present
GUI_LAYER const int The Unity layer that all UghCamera instance will render.  (Defaults to 20.)
PixelsPerUnit float The number of pixels contained in the span of a single Unity unit.

_

Using UghCamera’s Class Functions

public Vector3 ScreenAnchorToPosition(UghSprite.Anchor anchor, Vector3 customAnchor)

Given an Anchor and a custom offset, this function will return a position, in Unity units, that corresponds to the location of the Anchor as it relates to the UghCamera. For example ScreenAncorToPosition(UghSprite.Anchor.TopCenter, Vector3.zero) will return a position that is at the top and center of the UghCamera’s rendered surface. (An UghSprite placed at this position will appear at the top and center of the screen.)