Skip to content

UnityVecExtensions

Namespace: Shadop.Archmage.Sdk

Extension methods for Vec2, Vec3, and Vec4.

public static class UnityVecExtensions

Inheritance ObjectUnityVecExtensions

To maximize performance and avoid garbage collection (GC) allocations in Unity, these extensions provide explicit, hardcoded overloads for standard numeric types.

The underlying generic type T can be one of the following:

  • Integer Types: byte, sbyte, short, ushort, int, uint, long, ulong
  • Floating-point Types: float, double

Note: The documentation below uses a generic syntax <T> for brevity, but the actual implementation uses explicit overloads for the types listed above.

Converts a floating-point Vec2 to a UnityEngine.Vector2. Supported for float and double.

public static Vector2 ToVector2(this Vec2<T> vec)

Vector2


Converts an integer Vec2 to a UnityEngine.Vector2Int. Supported for byte, sbyte, short, ushort, int, uint, long, and ulong.

public static Vector2Int ToVector2Int(this Vec2<T> vec)

Vector2Int


Converts a floating-point Vec3 to a UnityEngine.Vector3. Supported for float and double.

public static Vector3 ToVector3(this Vec3<T> vec)

Vector3


Converts an integer Vec3 to a UnityEngine.Vector3Int. Supported for byte, sbyte, short, ushort, int, uint, long, and ulong.

public static Vector3Int ToVector3Int(this Vec3<T> vec)

Vector3Int


Converts a Vec4 to a UnityEngine.Vector4. Because Unity does not have a standard Vector4Int type, this method is supported for all numeric types (both integer and floating-point).

public static Vector4 ToVector4(this Vec4<T> vec)

Vector4