/Constraint-coordinates-for-Unity

Limits of coordinates. Structure for unity on C#

Primary LanguageC#

Constraint-coordinates-for-Unity

Structure constraint coordinates for unity on C#.
Fields float min, max.

Functions

bool IsZero() - Return true if empty or min & max equals zero.
float Clamp(float) - Return clamped value in range between min and max.
float GetRandom() - Return random value in range between min and max.
bool IsOutOfLimits(float) - Return true if value out of limit coordinates.
bool IsOutOfLimits(float, bool) - Return true if value out of limit coordinates considering the direction.
public bool IsCloserMaxBound(float, float) - Return true if value closer maximum coordinate. Second float - Offset of maximum.
public bool IsCloserMinBound(float, float) - Return true if value closer minimum coordinate. Second float - Offset of minimum
void TransformToWorld(Transform) - Transform minimum and maximum coordinates to world space from target.
void TransformToLocal(Transform) - Transform minimum and maximum coordinates to local space from target.

Editor

Visual structure
inspector

Editor functions

Options - Show/Hide options buttons.
Cop - Copy the values to the buffer.
Past - Paste values from the buffer.
World/Local - Switch space coordinates (World/Local).
X,Y,Z -Axis - Start/Stop edit coordinates mode by selected axis

Edit coordinates mode

In scene view witch enabled edit coordinates mode.
scene

Copy Vector property

Optional method copy inspector value from Vector2.
In scripts enable line "#define CopyVectorProperty"
Attribute: [CoordsFromVector(string vector2PropertyName)]
On open inspector. If min & max equals zero then set values from vector.