Changes

Jump to navigation Jump to search
77 bytes added ,  17:54, 2 February 2020
Line 30: Line 30:  
==Built-in functions==
 
==Built-in functions==
 
===Math functions===
 
===Math functions===
Abs(x) – Returns the absolute value of x
+
* Abs(x) – Returns the absolute value of x
Pow(x, y) – Raises x to the power of y
+
* Pow(x, y) – Raises x to the power of y
Sqrt(x) – Returns the square root of x
+
* Sqrt(x) – Returns the square root of x
Log(x) – Returns the natural logarithm of x
+
* Log(x) – Returns the natural logarithm of x
Log10(x) – Returns the base 10 logarithm of x
+
* Log10(x) – Returns the base 10 logarithm of x
Round(x) – Rounds x to the nearest integer
+
* Round(x) – Rounds x to the nearest integer
Ceil(x) – Rounds x up to the nearest integer
+
* Ceil(x) – Rounds x up to the nearest integer
Floor(x) – Rounds x down to the nearest integer
+
* Floor(x) – Rounds x down to the nearest integer
Min(x, y) – Returns the smallest number between x and y
+
* Min(x, y) – Returns the smallest number between x and y
Max(x, y) – Returns the largest number between x and y
+
* Max(x, y) – Returns the largest number between x and y
Sign(x) – Returns -1, 0, 1 based on the sign of x
+
* Sign(x) – Returns -1, 0, 1 based on the sign of x
Sin(x) – Returns the sine of x
+
* Sin(x) – Returns the sine of x
Cos(x) – Returns the cosine of x
+
* Cos(x) – Returns the cosine of x
Lerp(a, b, t) – Interpolates between a and b using t
+
* Lerp(a, b, t) – Interpolates between a and b using t
Clamp(x, a, b) – Clamps x between a and b
+
* Clamp(x, a, b) – Clamps x between a and b
Clamp01(x) – Clamps x between 0 and 1
+
* Clamp01(x) – Clamps x between 0 and 1
 
===Enumerable functions===
 
===Enumerable functions===
 
These functions can be used on any C# enumerable, e.g. arrays, lists, dictionaries, sets, etc. You simply use the function on the enumerable, and pass an anonymous function as a parameter, using x to refer to the elements of the enumerable, e.g. employees.Where(x.Salary > 1000).OrderBy(x.Age).Select(x.Name), will return the names of all employees that make more than $1000 ordered by their age. They work exactly like LINQ extension methods, basically.
 
These functions can be used on any C# enumerable, e.g. arrays, lists, dictionaries, sets, etc. You simply use the function on the enumerable, and pass an anonymous function as a parameter, using x to refer to the elements of the enumerable, e.g. employees.Where(x.Salary > 1000).OrderBy(x.Age).Select(x.Name), will return the names of all employees that make more than $1000 ordered by their age. They work exactly like LINQ extension methods, basically.
   −
Any(func) – Returns whether any elements satisfy func(x)
+
* Any(func) – Returns whether any elements satisfy func(x)
All(func) – Returns whether all elements satisfy func(x)
+
* All(func) – Returns whether all elements satisfy func(x)
None(func) - Returns whether no elements satisfy func(x)
+
* None(func) - Returns whether no elements satisfy func(x)
ForEach(func) – Runs func(x) on all elements
+
* ForEach(func) – Runs func(x) on all elements
Select(func) – Runs func(x) on all elements and returns the result
+
* Select(func) – Runs func(x) on all elements and returns the result
SelectMany(func) – Assuming input is an enumerable of enumerables, runs func(x) on elements in each sub enumerable and returns it as a flat enumerable
+
* SelectMany(func) – Assuming input is an enumerable of enumerables, runs func(x) on elements in each sub enumerable and returns it as a flat enumerable
Count(func) – Returns how many elements satisfy func(x)
+
* Count(func) – Returns how many elements satisfy func(x)
Where(func) – Returns elements that satisfy func(x)
+
* Where(func) – Returns elements that satisfy func(x)
FindFirst(func) – Returns the first element that satisfies func(x)
+
* FindFirst(func) – Returns the first element that satisfies func(x)
OrderBy(func) – Returns elements sorted by func(x) in ascending order
+
* OrderBy(func) – Returns elements sorted by func(x) in ascending order
OrderByDescending(func) – Pretty obvious
+
* OrderByDescending(func) – Pretty obvious
Distinct() – Returns only unique elements in the enumerable
+
* Distinct() – Returns only unique elements in the enumerable
Sum(func) – Returns the sum of running func(x) on all elements
+
* Sum(func) – Returns the sum of running func(x) on all elements
Average(func) – Returns the sum of running func(x) on all elements divided by the amount of elements
+
* Average(func) – Returns the sum of running func(x) on all elements divided by the amount of elements
Size() – Returns how many elements there are in the enumerable
+
* Size() – Returns how many elements there are in the enumerable
GetRandomElement() – Returns a random element from the enumerable
+
* GetRandomElement() – Returns a random element from the enumerable
 +
 
 
===Other functions===
 
===Other functions===
String(x) – Converts x to a string, using C# .ToString()
+
* String(x) – Converts x to a string, using C# .ToString()
FormatString(x, y) – Converts x to a string with a format string y using C# .Tostring(format)
+
* FormatString(x, y) – Converts x to a string with a format string y using C# .Tostring(format)
Debug(x) – Writes x to the log using Unity’s log system
+
* Debug(x) – Writes x to the log using Unity’s log system
Random() – Returns a random decimal number between 0 and 1
+
* Random() – Returns a random decimal number between 0 and 1
RandomRange(x, y) – Returns a random decimal number between x and y
+
* RandomRange(x, y) – Returns a random decimal number between x and y
RandomInteger(x, y) – Returns a random integer between x and y(exclusive)
+
* RandomInteger(x, y) – Returns a random integer between x and y(exclusive)

Navigation menu