Skip to content

API.Unity.Util Extensions

JuDelCo edited this page Mar 25, 2021 · 28 revisions

Note: Add first using Ju.Extensions; so you can use these extension methods.

LayerMask Extensions

// For GameObject, Collision and Collider classes
bool IsInLayerMask(LayerMask layerMask);

Color & Color32

Allows implicit and explicit conversion of Color & Color32 structs to and from the Unity ones.

Observable Extensions

This method will use a BehaviourLinkHandler to subscribe the Behaviour to the Observable.

void Subscribe<T>(Behaviour actor, Action<T> action, bool alwaysActive = false);

Random Extensions

Vector2Int Vector2i(Vector2Int min, Vector2Int max);
Vector2 Direction2D();
Vector2 Vector2f();
Vector2 Vector2f(Vector2 min, Vector2 max);

Vector3Int Vector3i(Vector3Int min, Vector3Int max);
Vector3 Direction3D();
Vector3 Vector3f();
Vector3 Vector3f(Vector3 min, Vector3 max);

Vector4 Vector4f();
Vector4 Vector4f(Vector4 min, Vector4 max);

Quaternion DirectionQuat();
Quaternion Quat();
Clone this wiki locally