Class Utils
Class with helper functions.
Inheritance
Inherited Members
Namespace: FlaxEngine
Assembly: FlaxEngine.CSharp.dll
Syntax
public static class Utils
Methods
ArraysEqual<T>(T[], T[])
Determines whether two arrays are equal by comparing the elements by using the default equality comparer for their type.
Declaration
public static bool ArraysEqual<T>(T[] a1, T[] a2)
Parameters
T[]
a1
The first array. |
T[]
a2
The second array. |
Returns
System.Boolean
|
Type Parameters
T
The type of the elements of the input sequences. |
ArraysEqual<T>(T[], IReadOnlyList<T>)
Determines whether two arrays are equal by comparing the elements by using the default equality comparer for their type.
Declaration
public static bool ArraysEqual<T>(T[] a1, IReadOnlyList<T> a2)
Parameters
T[]
a1
The first array. |
System.Collections.Generic.IReadOnlyList<T>
a2
The second array. |
Returns
System.Boolean
|
Type Parameters
T
The type of the elements of the input sequences. |
ArraysEqual<T>(List<T>, List<T>)
Determines whether two arrays are equal by comparing the elements by using the default equality comparer for their type.
Declaration
public static bool ArraysEqual<T>(List<T> a1, List<T> a2)
Parameters
System.Collections.Generic.List<T>
a1
The first array. |
System.Collections.Generic.List<T>
a2
The second array. |
Returns
System.Boolean
|
Type Parameters
T
The type of the elements of the input sequences. |
GetAssemblyByName(String)
Gets the assembly with the given name.
Declaration
public static Assembly GetAssemblyByName(string name)
Parameters
System.String
name
The name. |
Returns
System.Reflection.Assembly
The assembly or null if not found. |
GetAssemblyByName(String, Assembly[])
Gets the assembly with the given name.
Declaration
public static Assembly GetAssemblyByName(string name, Assembly[] assemblies)
Parameters
System.String
name
The name. |
System.Reflection.Assembly[]
assemblies
The assemblies collection to search for. |
Returns
System.Reflection.Assembly
The assembly or null if not found. |
GetEmptyArray<T>()
Gets the empty array of the given type (shared one).
Declaration
public static T[] GetEmptyArray<T>()
Returns
T[]
The empty array object. |
Type Parameters
T
The type. |
MemoryClear(IntPtr, UInt64)
Clears the memory region with zeros.
Declaration
public static void MemoryClear(IntPtr dst, ulong size)
Parameters
System.IntPtr
dst
Destination memory address |
System.UInt64
size
Size of the memory to clear in bytes |
Remarks
Uses low-level platform impl.
MemoryCompare(IntPtr, IntPtr, UInt64)
Compares two blocks of the memory.
Declaration
public static int MemoryCompare(IntPtr buf1, IntPtr buf2, ulong size)
Parameters
System.IntPtr
buf1
The first buffer address. |
System.IntPtr
buf2
The second buffer address. |
System.UInt64
size
Size of the memory to compare in bytes. |
Returns
System.Int32
|
Remarks
Uses low-level platform impl.
MemoryCopy(IntPtr, IntPtr, Int32)
Copies data from one memory location to another using an unmanaged memory pointers.
Declaration
[Obsolete("Use MemoryCopy with long length and source/destination swapped to match C++ API.")]
public static void MemoryCopy(IntPtr source, IntPtr destination, int length)
Parameters
System.IntPtr
source
The source location. |
System.IntPtr
destination
The destination location. |
System.Int32
length
The length (amount of bytes to copy). |
Remarks
Uses low-level platform impl.
MemoryCopy(IntPtr, IntPtr, UInt64)
Copies data from one memory location to another using an unmanaged memory pointers.
Declaration
public static void MemoryCopy(IntPtr destination, IntPtr source, ulong length)
Parameters
System.IntPtr
destination
The destination location. |
System.IntPtr
source
The source location. |
System.UInt64
length
The length (amount of bytes to copy). |
Remarks
Uses low-level platform impl.
ReadBoundingBox(BinaryReader)
Reads the BoundingBox from the binary stream.
Declaration
public static BoundingBox ReadBoundingBox(this BinaryReader stream)
Parameters
System.IO.BinaryReader
stream
The stream. |
Returns
BoundingBox
The value. |
ReadBoundingSphere(BinaryReader)
Reads the BoundingSphere from the binary stream.
Declaration
public static BoundingSphere ReadBoundingSphere(this BinaryReader stream)
Parameters
System.IO.BinaryReader
stream
The stream. |
Returns
BoundingSphere
The value. |
ReadColor(BinaryReader)
Reads the color from the binary stream.
Declaration
public static Color ReadColor(this BinaryReader stream)
Parameters
System.IO.BinaryReader
stream
The stream. |
Returns
Color
The value. |
ReadColor32(BinaryReader)
Reads the color from the binary stream.
Declaration
public static Color32 ReadColor32(this BinaryReader stream)
Parameters
System.IO.BinaryReader
stream
The stream. |
Returns
Color32
The value. |
ReadInt2(BinaryReader)
Reads the Int2 from the binary stream.
Declaration
public static Int2 ReadInt2(this BinaryReader stream)
Parameters
System.IO.BinaryReader
stream
The stream. |
Returns
Int2
The value. |
ReadInt3(BinaryReader)
Reads the Int3 from the binary stream.
Declaration
public static Int3 ReadInt3(this BinaryReader stream)
Parameters
System.IO.BinaryReader
stream
The stream. |
Returns
Int3
The value. |
ReadInt4(BinaryReader)
Reads the Int4 from the binary stream.
Declaration
public static Int4 ReadInt4(this BinaryReader stream)
Parameters
System.IO.BinaryReader
stream
The stream. |
Returns
Int4
The value. |
ReadJson(BinaryReader, ISerializable)
Deserializes object from Json by reading it as a raw data (ver+length+bytes).
Declaration
public static void ReadJson(this BinaryReader stream, ISerializable obj)
Parameters
System.IO.BinaryReader
stream
The stream. |
ISerializable
obj
The object to deserialize. |
Remarks
Reads version number, data length and actual data bytes from the stream.
ReadMatrix(BinaryReader)
Reads the Matrix from the binary stream.
Declaration
public static Matrix ReadMatrix(this BinaryReader stream)
Parameters
System.IO.BinaryReader
stream
The stream. |
Returns
Matrix
The value. |
ReadQuaternion(BinaryReader)
Reads the Quaternion from the binary stream.
Declaration
public static Quaternion ReadQuaternion(this BinaryReader stream)
Parameters
System.IO.BinaryReader
stream
The stream. |
Returns
Quaternion
The value. |
ReadRay(BinaryReader)
Reads the Ray from the binary stream.
Declaration
public static Ray ReadRay(this BinaryReader stream)
Parameters
System.IO.BinaryReader
stream
The stream. |
Returns
Ray
The value. |
ReadTransform(BinaryReader)
Reads the Transform from the binary stream.
Declaration
public static Transform ReadTransform(this BinaryReader stream)
Parameters
System.IO.BinaryReader
stream
The stream. |
Returns
Transform
The value. |
ReadVector2(BinaryReader)
Reads the Vector2 from the binary stream.
Declaration
public static Vector2 ReadVector2(this BinaryReader stream)
Parameters
System.IO.BinaryReader
stream
The stream. |
Returns
Vector2
The value. |
ReadVector3(BinaryReader)
Reads the Vector3 from the binary stream.
Declaration
public static Vector3 ReadVector3(this BinaryReader stream)
Parameters
System.IO.BinaryReader
stream
The stream. |
Returns
Vector3
The value. |
ReadVector4(BinaryReader)
Reads the Vector4 from the binary stream.
Declaration
public static Vector4 ReadVector4(this BinaryReader stream)
Parameters
System.IO.BinaryReader
stream
The stream. |
Returns
Vector4
The value. |
RoundTo1DecimalPlace(Single)
Rounds the floating point value up to 1 decimal place.
Declaration
public static float RoundTo1DecimalPlace(float value)
Parameters
System.Single
value
The value. |
Returns
System.Single
The rounded result. |
RoundTo2DecimalPlaces(Single)
Rounds the floating point value up to 2 decimal places.
Declaration
public static float RoundTo2DecimalPlaces(float value)
Parameters
System.Single
value
The value. |
Returns
System.Single
The rounded result. |
RoundTo3DecimalPlaces(Single)
Rounds the floating point value up to 3 decimal places.
Declaration
public static float RoundTo3DecimalPlaces(float value)
Parameters
System.Single
value
The value. |
Returns
System.Single
The rounded result. |
Write(BinaryWriter, BoundingBox)
Writes the BoundingBox to the binary stream.
Declaration
public static void Write(this BinaryWriter stream, BoundingBox value)
Parameters
System.IO.BinaryWriter
stream
The stream. |
BoundingBox
value
The value to write. |
Write(BinaryWriter, BoundingSphere)
Writes the BoundingSphere to the binary stream.
Declaration
public static void Write(this BinaryWriter stream, BoundingSphere value)
Parameters
System.IO.BinaryWriter
stream
The stream. |
BoundingSphere
value
The value to write. |
Write(BinaryWriter, Color)
Writes the color to the binary stream.
Declaration
public static void Write(this BinaryWriter stream, Color value)
Parameters
System.IO.BinaryWriter
stream
The stream. |
Color
value
The value to write. |
Write(BinaryWriter, Color32)
Writes the color to the binary stream.
Declaration
public static void Write(this BinaryWriter stream, Color32 value)
Parameters
System.IO.BinaryWriter
stream
The stream. |
Color32
value
The value to write. |
Write(BinaryWriter, Int2)
Writes the Int2 to the binary stream.
Declaration
public static void Write(this BinaryWriter stream, Int2 value)
Parameters
System.IO.BinaryWriter
stream
The stream. |
Int2
value
The value to write. |
Write(BinaryWriter, Int3)
Writes the Int3 to the binary stream.
Declaration
public static void Write(this BinaryWriter stream, Int3 value)
Parameters
System.IO.BinaryWriter
stream
The stream. |
Int3
value
The value to write. |
Write(BinaryWriter, Int4)
Writes the Int4 to the binary stream.
Declaration
public static void Write(this BinaryWriter stream, Int4 value)
Parameters
System.IO.BinaryWriter
stream
The stream. |
Int4
value
The value to write. |
Write(BinaryWriter, Matrix)
Writes the Matrix to the binary stream.
Declaration
public static void Write(this BinaryWriter stream, Matrix value)
Parameters
System.IO.BinaryWriter
stream
The stream. |
Matrix
value
The value to write. |
Write(BinaryWriter, Quaternion)
Writes the Quaternion to the binary stream.
Declaration
public static void Write(this BinaryWriter stream, Quaternion value)
Parameters
System.IO.BinaryWriter
stream
The stream. |
Quaternion
value
The value to write. |
Write(BinaryWriter, Ray)
Writes the Ray to the binary stream.
Declaration
public static void Write(this BinaryWriter stream, Ray value)
Parameters
System.IO.BinaryWriter
stream
The stream. |
Ray
value
The value to write. |
Write(BinaryWriter, Rectangle)
Writes the Rectangle to the binary stream.
Declaration
public static void Write(this BinaryWriter stream, Rectangle value)
Parameters
System.IO.BinaryWriter
stream
The stream. |
Rectangle
value
The value to write. |
Write(BinaryWriter, Transform)
Writes the Transform to the binary stream.
Declaration
public static void Write(this BinaryWriter stream, Transform value)
Parameters
System.IO.BinaryWriter
stream
The stream. |
Transform
value
The value to write. |
Write(BinaryWriter, Vector2)
Writes the Vector2 to the binary stream.
Declaration
public static void Write(this BinaryWriter stream, Vector2 value)
Parameters
System.IO.BinaryWriter
stream
The stream. |
Vector2
value
The value to write. |
Write(BinaryWriter, Vector3)
Writes the Vector3 to the binary stream.
Declaration
public static void Write(this BinaryWriter stream, Vector3 value)
Parameters
System.IO.BinaryWriter
stream
The stream. |
Vector3
value
The value to write. |
Write(BinaryWriter, Vector4)
Writes the Vector4 to the binary stream.
Declaration
public static void Write(this BinaryWriter stream, Vector4 value)
Parameters
System.IO.BinaryWriter
stream
The stream. |
Vector4
value
The value to write. |
WriteJson(BinaryWriter, ISerializable)
Serializes object to Json and writes it as a raw data (ver+length+bytes).
Declaration
public static void WriteJson(this BinaryWriter stream, ISerializable obj)
Parameters
System.IO.BinaryWriter
stream
The stream. |
ISerializable
obj
The object to serialize. |
Remarks
Writes version number, data length and actual data bytes to the stream.