Inherits IUseCamera.
Public Types | |
enum | HORIZONTAL_ALIGN { NONE, SCREEN_LEFT, SCREEN_RIGHT, SCREEN_CENTER, OBJECT } |
Specifies what the object will be aligned relative to on the horizontal axis. More... | |
enum | VERTICAL_ALIGN { NONE, SCREEN_TOP, SCREEN_BOTTOM, SCREEN_CENTER, OBJECT } |
Specifies what the object will be aligned relative to on the vertical axis. More... | |
Public Member Functions | |
void | PositionOnScreenRecursively () |
Positions the object, taking into account any object-relative dependencies, making sure the objects to which this object is relative are correctly positioned before positioning this one. | |
Vector3 | ScreenPosToLocalPos (Vector3 screenPos) |
Calculates a local position from a given screen or object-relative position, according to the current screen-space settings. | |
Vector3 | ScreenPosToParentPos (Vector3 screenPos) |
Calculates a in the parent's local space from a given screen or object-relative position, according to the current screen-space settings. | |
Vector3 | ScreenPosToWorldPos (Vector3 screenPos) |
void | PositionOnScreen () |
Repositions the object using the existing screen-space settings. | |
void | PositionOnScreen (int x, int y, float depth) |
Positions the object using screen coordinates, according to the relativity settings stored in relativeToScreen. | |
void | PositionOnScreen (Vector3 pos) |
Positions the object using screen coordinates, according to the relativity settings stored in relativeToScreen. | |
void | SetCamera () |
A no-argument version of SetCamera() that simply re-assigns the same camera to the object, forcing it to recalculate all camera-dependent calculations. | |
void | SetCamera (Camera c) |
Sets the camera to be used for calculating positions. | |
Public Attributes | |
Camera | renderCamera |
The camera with which this object should be positioned. | |
Vector3 | screenPos = Vector3.forward |
The position of the object, relative to the screen or other object. | |
bool | ignoreZ = false |
When set to true, the Z component of Screen Pos will be calculated based upon the distance of the object to the render camera, rather than controlling the distance to the render camera. Enable this option, for example, when you want to preserve parent-relative positioning on the Z-axis. | |
RelativeTo | relativeTo |
Settings object that describes what this object is positioned relative to. | |
Transform | relativeObject |
The object to which this object is relative. NOTE: Only used if either the vertical or horizontal elements of relativeTo are set to OBJECT (or both). | |
bool | alwaysRecursive = true |
When true, positioning of the object is always done in a recursive fashion. That is, if this object is relative to any other objects, those objects, should they also hold an EZScreenPlacement component, will be positioned before this one. | |
bool | allowTransformDrag = false |
When checked, you can simply use the transform handles in the scene view to roughly position your object in the scene, and the appropriate values will be automatically calculated for Screen Pos based on your other settings. If you're having problems with slight rounding errors making small changes to your Screen Pos coordinate, you should probably uncheck this option. This is particularly likely to happen if your camera is rotated at all. | |
Properties | |
Camera | RenderCamera [get, set] |
Accessor for the camera that will be used to render this object. Use this to ensure the object is properly configured for the specific camera that will render it. | |
Vector3 | ScreenCoord [get] |
Retrieves the screen coordinate of the object's current position. |
A class that eases the process of placing objects on-screen in a screen-relative, or object-relative way, using pixels as units of distance.
Specifies what the object will be aligned relative to on the horizontal axis.
Specifies what the object will be aligned relative to on the vertical axis.
void EZScreenPlacement.PositionOnScreen | ( | Vector3 | pos | ) |
Positions the object using screen coordinates, according to the relativity settings stored in relativeToScreen.
pos | The X and Y screen coordinates where the object should be positioned, as well as the Z coordinate which represents the distance in front of the camera. |
void EZScreenPlacement.PositionOnScreen | ( | int | x, | |
int | y, | |||
float | depth | |||
) |
Positions the object using screen coordinates, according to the relativity settings stored in relativeToScreen.
x | The number of pixels in the X axis relative to the position specified in relativeToScreen. | |
y | The number of pixels in the Y axis relative to the position specified in relativeToScreen. | |
depth | The distance the object should be in front of the camera. |
void EZScreenPlacement.PositionOnScreen | ( | ) |
Repositions the object using the existing screen-space settings.
void EZScreenPlacement.PositionOnScreenRecursively | ( | ) |
Positions the object, taking into account any object-relative dependencies, making sure the objects to which this object is relative are correctly positioned before positioning this one.
Vector3 EZScreenPlacement.ScreenPosToLocalPos | ( | Vector3 | screenPos | ) |
Calculates a local position from a given screen or object-relative position, according to the current screen-space settings.
screenPos | The screen/object-relative position |
Vector3 EZScreenPlacement.ScreenPosToParentPos | ( | Vector3 | screenPos | ) |
Calculates a in the parent's local space from a given screen or object-relative position, according to the current screen-space settings.
screenPos | The screen/object-relative position |
Vector3 EZScreenPlacement.ScreenPosToWorldPos | ( | Vector3 | screenPos | ) |
Calculates the world position from a given screen or object-relative position, according to the current screen-space settings.
screenPos | The screen/object-relative position |
void EZScreenPlacement.SetCamera | ( | Camera | c | ) |
Sets the camera to be used for calculating positions.
c |
void EZScreenPlacement.SetCamera | ( | ) |
A no-argument version of SetCamera() that simply re-assigns the same camera to the object, forcing it to recalculate all camera-dependent calculations.
bool EZScreenPlacement.allowTransformDrag = false |
When checked, you can simply use the transform handles in the scene view to roughly position your object in the scene, and the appropriate values will be automatically calculated for Screen Pos based on your other settings. If you're having problems with slight rounding errors making small changes to your Screen Pos coordinate, you should probably uncheck this option. This is particularly likely to happen if your camera is rotated at all.
bool EZScreenPlacement.alwaysRecursive = true |
When true, positioning of the object is always done in a recursive fashion. That is, if this object is relative to any other objects, those objects, should they also hold an EZScreenPlacement component, will be positioned before this one.
bool EZScreenPlacement.ignoreZ = false |
When set to true, the Z component of Screen Pos will be calculated based upon the distance of the object to the render camera, rather than controlling the distance to the render camera. Enable this option, for example, when you want to preserve parent-relative positioning on the Z-axis.
Transform EZScreenPlacement.relativeObject |
The object to which this object is relative. NOTE: Only used if either the vertical or horizontal elements of relativeTo are set to OBJECT (or both).
RelativeTo EZScreenPlacement.relativeTo |
Settings object that describes what this object is positioned relative to.
The camera with which this object should be positioned.
Vector3 EZScreenPlacement.screenPos = Vector3.forward |
The position of the object, relative to the screen or other object.
Camera EZScreenPlacement.RenderCamera [get, set] |
Accessor for the camera that will be used to render this object. Use this to ensure the object is properly configured for the specific camera that will render it.
Vector3 EZScreenPlacement.ScreenCoord [get] |
Retrieves the screen coordinate of the object's current position.