Search Results for

    Show / Hide Table of Contents

    Class Utils

    Class with helper functions.

    Inheritance
    System.Object
    Utils
    Namespace: FlaxEngine
    Assembly: FlaxEngine.CSharp.dll
    Syntax
    public static class Utils : Object

    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

    true if the two source sequences are of equal length and their corresponding elements are equal according to the default equality comparer for their type; otherwise, false.

    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

    true if the two source sequences are of equal length and their corresponding elements are equal according to the default equality comparer for their type; otherwise, false.

    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

    true if the two source sequences are of equal length and their corresponding elements are equal according to the default equality comparer for their type; otherwise, false.

    Type Parameters
    T

    The type of the elements of the input sequences.

    GetAssemblies()

    Gets all currently loaded assemblies in the runtime.

    Declaration
    public static Assembly[] GetAssemblies()
    Returns
    System.Reflection.Assembly[]

    List of assemblies

    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.

    GetAssemblyLocation(Assembly)

    Gets the location of the assembly.

    Declaration
    public static string GetAssemblyLocation(Assembly assembly)
    Parameters
    System.Reflection.Assembly assembly

    The assembly.

    Returns
    System.String

    Path in the filesystem

    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.

    GetParameterTypes(MethodBase)

    Gets the array of method parameter types.

    Declaration
    public static Type[] GetParameterTypes(this MethodBase method)
    Parameters
    System.Reflection.MethodBase method

    The method to get it's parameters.

    Returns
    System.Type[]

    Method parameters array.

    InitStructure(Object, Type)

    Initializes the structure (value type) by inflating it with values from System.ComponentModel.DefaultValueAttribute (recursive).

    Declaration
    public static void InitStructure(object obj, Type type)
    Parameters
    System.Object obj

    The object to initialize.

    System.Type type

    The structure type.

    MemoryClear(IntPtr, UInt64)

    Clears the memory region with zeros.

    Declaration
    public static extern 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 extern 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
    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 extern 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.

    ReadDouble2(BinaryReader)

    Reads the Double2 from the binary stream.

    Declaration
    public static Double2 ReadDouble2(this BinaryReader stream)
    Parameters
    System.IO.BinaryReader stream

    The stream.

    Returns
    Double2

    The value.

    ReadDouble3(BinaryReader)

    Reads the Double3 from the binary stream.

    Declaration
    public static Double3 ReadDouble3(this BinaryReader stream)
    Parameters
    System.IO.BinaryReader stream

    The stream.

    Returns
    Double3

    The value.

    ReadDouble4(BinaryReader)

    Reads the Double4 from the binary stream.

    Declaration
    public static Double4 ReadDouble4(this BinaryReader stream)
    Parameters
    System.IO.BinaryReader stream

    The stream.

    Returns
    Double4

    The value.

    ReadFloat2(BinaryReader)

    Reads the Float2 from the binary stream.

    Declaration
    public static Float2 ReadFloat2(this BinaryReader stream)
    Parameters
    System.IO.BinaryReader stream

    The stream.

    Returns
    Float2

    The value.

    ReadFloat3(BinaryReader)

    Reads the Float3 from the binary stream.

    Declaration
    public static Float3 ReadFloat3(this BinaryReader stream)
    Parameters
    System.IO.BinaryReader stream

    The stream.

    Returns
    Float3

    The value.

    ReadFloat4(BinaryReader)

    Reads the Float4 from the binary stream.

    Declaration
    public static Float4 ReadFloat4(this BinaryReader stream)
    Parameters
    System.IO.BinaryReader stream

    The stream.

    Returns
    Float4

    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.

    ReadVector2(BinaryReader, Boolean)

    Reads the Vector2 from the binary stream.

    Declaration
    public static Vector2 ReadVector2(this BinaryReader stream, bool useDouble)
    Parameters
    System.IO.BinaryReader stream

    The stream.

    System.Boolean useDouble

    True to explicitly use 64-bit precision for serialized data, otherwise will use 32-bit precision.

    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.

    ReadVector3(BinaryReader, Boolean)

    Reads the Vector3 from the binary stream.

    Declaration
    public static Vector3 ReadVector3(this BinaryReader stream, bool useDouble)
    Parameters
    System.IO.BinaryReader stream

    The stream.

    System.Boolean useDouble

    True to explicitly use 64-bit precision for serialized data, otherwise will use 32-bit precision.

    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.

    ReadVector4(BinaryReader, Boolean)

    Reads the Vector4 from the binary stream.

    Declaration
    public static Vector4 ReadVector4(this BinaryReader stream, bool useDouble)
    Parameters
    System.IO.BinaryReader stream

    The stream.

    System.Boolean useDouble

    True to explicitly use 64-bit precision for serialized data, otherwise will use 32-bit precision.

    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, Double2)

    Writes the Vector2 to the binary stream.

    Declaration
    public static void Write(this BinaryWriter stream, Double2 value)
    Parameters
    System.IO.BinaryWriter stream

    The stream.

    Double2 value

    The value to write.

    Write(BinaryWriter, Double3)

    Writes the Vector3 to the binary stream.

    Declaration
    public static void Write(this BinaryWriter stream, Double3 value)
    Parameters
    System.IO.BinaryWriter stream

    The stream.

    Double3 value

    The value to write.

    Write(BinaryWriter, Double4)

    Writes the Vector4 to the binary stream.

    Declaration
    public static void Write(this BinaryWriter stream, Double4 value)
    Parameters
    System.IO.BinaryWriter stream

    The stream.

    Double4 value

    The value to write.

    Write(BinaryWriter, Float2)

    Writes the Vector2 to the binary stream.

    Declaration
    public static void Write(this BinaryWriter stream, Float2 value)
    Parameters
    System.IO.BinaryWriter stream

    The stream.

    Float2 value

    The value to write.

    Write(BinaryWriter, Float3)

    Writes the Vector3 to the binary stream.

    Declaration
    public static void Write(this BinaryWriter stream, Float3 value)
    Parameters
    System.IO.BinaryWriter stream

    The stream.

    Float3 value

    The value to write.

    Write(BinaryWriter, Float4)

    Writes the Vector4 to the binary stream.

    Declaration
    public static void Write(this BinaryWriter stream, Float4 value)
    Parameters
    System.IO.BinaryWriter stream

    The stream.

    Float4 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, Vector2, Boolean)

    Writes the Vector2 to the binary stream.

    Declaration
    public static void Write(this BinaryWriter stream, Vector2 value, bool useDouble)
    Parameters
    System.IO.BinaryWriter stream

    The stream.

    Vector2 value

    The value to write.

    System.Boolean useDouble

    True to explicitly use 64-bit precision for serialized data, otherwise will use 32-bit precision.

    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, Vector3, Boolean)

    Writes the Vector3 to the binary stream.

    Declaration
    public static void Write(this BinaryWriter stream, Vector3 value, bool useDouble)
    Parameters
    System.IO.BinaryWriter stream

    The stream.

    Vector3 value

    The value to write.

    System.Boolean useDouble

    True to explicitly use 64-bit precision for serialized data, otherwise will use 32-bit precision.

    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.

    Write(BinaryWriter, Vector4, Boolean)

    Writes the Vector4 to the binary stream.

    Declaration
    public static void Write(this BinaryWriter stream, Vector4 value, bool useDouble)
    Parameters
    System.IO.BinaryWriter stream

    The stream.

    Vector4 value

    The value to write.

    System.Boolean useDouble

    True to explicitly use 64-bit precision for serialized data, otherwise will use 32-bit precision.

    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.

    In This Article
    Back to top Copyright © 2012-2024 Wojciech Figat