API.Unity.Util Extensions - JuDelCo/Core GitHub Wiki

Namespaces: Ju.Extensions + The namespace use for each util class

Editor Attributes

[ReadOnly]

LayerMask Extensions

For Unity 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);

Clock Constructors

Clock(Behaviour behaviour, bool alwaysActive = false);
Clock(float elapsedSeconds, Behaviour behaviour, bool alwaysActive = false);

Timer Constructor

Timer(float seconds, Action onCompleted, Behaviour behaviour, bool alwaysActive = false);

FrameTimer Constructor

FrameTimer(int frames, Action onCompleted, Behaviour behaviour, bool alwaysActive = false);

JNode extensions

JData<Color> AsDataUnityColor();
JData<Color32> AsDataUnityColor32();
JData<Vector2> AsDataVector2();
JData<Vector2Int> AsDataVector2Int();
JData<Vector3> AsDataVector3();
JData<Vector3Int> AsDataVector3Int();
JData<Vector4> AsDataVector4();

JDict protected methods

// Useful when defining your own struct based on JDict
protected JData<Color> GetDataUnityColor(string key);
protected JData<Color32> GetDataUnityColor32(string key);
protected JData<Vector2> GetDataVector2(string key);
protected JData<Vector2Int> GetDataVector2Int(string key);
protected JData<Vector3> GetDataVector3(string key);
protected JData<Vector3Int> GetDataVector3Int(string key);
protected JData<Vector4> GetDataVector4(string key);

JData< T > extensions

// Extension methods for JData<string> only
Color AsUnityColor(Color defaultValue = default(Color));
Color32 AsUnityColor32(Color32 defaultValue = default(Color32));
Vector2 AsVector2(Vector2 defaultValue = default(Vector2));
Vector2Int AsVector2Int(Vector2Int defaultValue = default(Vector2Int));
Vector3 AsVector3(Vector3 defaultValue = default(Vector3));
Vector3Int AsVector3Int(Vector3Int defaultValue = default(Vector3Int));
Vector4 AsVector4(Vector4 defaultValue = default(Vector4));
void Set(Color value, bool prependHashChar = false);
void Set(Color32 value, bool prependHashChar = false);
void Set(Vector2 value);
void Set(Vector2Int value);
void Set(Vector3 value);
void Set(Vector3Int value);
void Set(Vector4 value);

Conversion Cast Extensions

// Cast.This(string)
Color AsUnityColor(Color defaultValue = default(Color));
Color32 AsUnityColor32(Color32 defaultValue = default(Color32));
Vector2 AsVector2(Vector2 defaultValue = default(Vector2));
Vector2Int AsVector2Int(Vector2Int defaultValue = default(Vector2Int));
Vector3 AsVector3(Vector3 defaultValue = default(Vector3));
Vector3Int AsVector3Int(Vector3Int defaultValue = default(Vector3Int));
Vector4 AsVector4(Vector4 defaultValue = default(Vector4));

// Cast.This(Color)
string AsString(bool prependHashChar = true, bool toUpper = true);

// Cast.This(Color32)
string AsString(bool prependHashChar = true, bool toUpper = true);

// Cast.This(Vector2)
string AsString();

// Cast.This(Vector2Int)
string AsString();

// Cast.This(Vector3)
string AsString();

// Cast.This(Vector3Int)
string AsString();

// Cast.This(Vector4)
string AsString();

DataTypeConverter Converters

From Type To Type
(Unity) Color (Unity) Color32
(Unity) Color (Core) Color
(Unity) Color (Core) Color32
(Unity) Color32 (Unity) Color
(Unity) Color32 (Core) Color
(Unity) Color32 (Core) Color32
Vector2Int Vector2
Vector3Int Vector3
Vector2 Vector2Int
Vector3 Vector3Int
Color string
Color32 string
Vector2 string
Vector2Int string
Vector3 string
Vector3Int string
Vector4 string
string Color
string Color32
string Vector2
string Vector2Int
string Vector3
string Vector3Int
string Vector4

JsonValue Extensions

Color GetValue(Color defaultValue = default(Color));
Color32 GetValue(Color32 defaultValue = default(Color32));
Vector2 GetValue(Vector2 defaultValue = default(Vector2));
Vector2Int GetValue(Vector2Int defaultValue = default(Vector2Int));
Vector3 GetValue(Vector3 defaultValue = default(Vector3));
Vector3Int GetValue(Vector3Int defaultValue = default(Vector3Int));
Vector4 GetValue(Vector4 defaultValue = default(Vector4));

JsonObject Extensions

Color GetValue(string key, Color defaultValue = default(Color));
Color32 GetValue(string key, Color32 defaultValue = default(Color32));
Vector2 GetValue(string key, Vector2 defaultValue = default(Vector2));
Vector2Int GetValue(string key, Vector2Int defaultValue = default(Vector2Int));
Vector3 GetValue(string key, Vector3 defaultValue = default(Vector3));
Vector3Int GetValue(string key, Vector3Int defaultValue = default(Vector3Int));
Vector4 GetValue(string key, Vector4 defaultValue = default(Vector4);
⚠️ **GitHub.com Fallback** ⚠️