Extensions

An extension methods for Unity

Extension Method is a very important function in c#. This is a start point of Functional Programming in c#.

<sourcearrow-up-right>

circle-info

please read this Microsoft official documentarrow-up-right.


Array

int[] data = { 0, 1, 2, 3, 4, 5 };

// swap 2 elements in array
data.SwapElements(2, 5);    // output 0, 1, 5, 3, 4, 2
circle-info

if given index is out of range, it will clamp to the range.


Bounds

// get random point in Bounds object
Vector3 randomPoint = myBound.RandomPoint();

byte

byte b = 16;

// convert to volume formatted string
var size = b.SizeSuffix(2)    // size = "16 bytes"

// convert to Currency formatted string
var amount = b.CurrencySuffix(2)    // amount = "16"

Color


DateTime


Dictionary

circle-info

Log Warning if given index of SwapValues is out of range


float


IEnumerable


int


LayerMask


long


Mathmatics.float2


Mathmatics.float3


Mathmatics.float4


Mathematics.quaternion


Quaternion


RectTransform


short


string

circle-info

please see package Aceland Task Utils.


Texture2D


Transform

circle-exclamation

Vector2


Vector2Int


Vector3


Vector3Int


Vector4


Last updated