docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class ReflectionUtils

    Set of various reflection utilities

    Inheritance
    object
    ReflectionUtils
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.Rendering.Tests
    Assembly: Unity.RenderPipelines.Core.Editor.Tests.dll
    Syntax
    public static class ReflectionUtils

    Methods

    FindTypeByName(string)

    Finds a type by full name

    Declaration
    public static Type FindTypeByName(string name)
    Parameters
    Type Name Description
    string name

    The full type name with namespace

    Returns
    Type Description
    Type

    The found type

    GetField(object, string)

    Gets the value of a private field from a class

    Declaration
    public static object GetField(this object target, string fieldName)
    Parameters
    Type Name Description
    object target

    The object instance that contains the field to be retrieved.

    string fieldName

    The name of the private field to get the value from.

    Returns
    Type Description
    object

    The value of the specified field from the target object.

    GetFields(object)

    Gets all the fields from a class

    Declaration
    public static IEnumerable<FieldInfo> GetFields(this object target)
    Parameters
    Type Name Description
    object target

    The object instance from which to get the fields.

    Returns
    Type Description
    IEnumerable<FieldInfo>

    An ordered enumeration of FieldInfo objects representing each field defined within the type of the target object.

    Invoke(object, string, params object[])

    Calls a private method from a class

    Declaration
    public static object Invoke(this object target, string methodName, params object[] args)
    Parameters
    Type Name Description
    object target

    The object instance on which to invoke the method.

    string methodName

    The method name

    object[] args

    The arguments to pass to the method

    Returns
    Type Description
    object

    The return value from the invoked method, or null if the method does not return a value.

    InvokeStatic(Type, string, params object[])

    Calls a private method from a class

    Declaration
    public static object InvokeStatic(this Type targetType, string methodName, params object[] args)
    Parameters
    Type Name Description
    Type targetType

    The Type on which to invoke the static method.

    string methodName

    The method name

    object[] args

    The arguments to pass to the method

    Returns
    Type Description
    object

    The return value from the static method invoked, or null for methods returning void.

    SetField(object, string, object)

    Sets a private field from a class

    Declaration
    public static void SetField(this object target, string fieldName, object value)
    Parameters
    Type Name Description
    object target

    The object instance that contains the field to be set.

    string fieldName

    The field to change

    object value

    The new value

    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)