logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class UnityReflectionCallTask

    Unity-specific reflection call task that inherits from ReflectionCallTask. Provides Unity instance activation (ScriptableObject, Component) and main-thread dispatching via UnityInstanceActivator and UnityMainThreadDispatcher.

    Applies a conservative dispatch policy: all reflected instance creation and method invocation are marshalled to the Unity main thread when a dispatcher is available, regardless of whether the method signature exposes Unity types. This is necessary because many methods use Unity APIs internally without exposing them in their signatures.

    Inheritance
    object
    UnityReflectionCallTask
    Namespace: Serenity.UnityGlobal.Infrastructure.Services
    Assembly: Serenity.UnityGlobal.Infrastructure.dll
    Syntax
    public class UnityReflectionCallTask : ReflectionCallTask

    Constructors

    UnityReflectionCallTask(string, TaskCriticality, float, string, string, bool, bool, IReadOnlyList<string>, ITaskServices, IReadOnlyList<string>, ILogService, IMainThreadDispatcher)

    Initializes a new instance of the UnityReflectionCallTask class.

    Declaration
    public UnityReflectionCallTask(string id, TaskCriticality criticality, float weight, string typeName, string methodName, bool resolveFromServices, bool isStatic, IReadOnlyList<string> stringArgs, ITaskServices services, IReadOnlyList<string> methodParamTypes, ILogService logService, IMainThreadDispatcher mainThreadDispatcher = null)
    Parameters
    Type Name Description
    string id

    Unique identifier for the task.

    TaskCriticality criticality

    Criticality level of the task.

    float weight

    Weight of the task, influencing its scheduling and resource allocation.

    string typeName

    The name of the type containing the method to invoke.

    string methodName

    The name of the method to invoke.

    bool resolveFromServices

    If true, the method's parameters will be resolved from the service container.

    bool isStatic

    Indicates whether the method to invoke is static.

    IReadOnlyList<string> stringArgs

    List of string arguments to pass to the method.

    ITaskServices services

    Service container for resolving dependencies.

    IReadOnlyList<string> methodParamTypes

    List of parameter type names for the method to invoke.

    ILogService logService

    Optional logging service for warnings and errors.

    IMainThreadDispatcher mainThreadDispatcher

    Optional main-thread dispatcher. If null, a new UnityMainThreadDispatcher with captured context is created.

    Methods

    ReportTypeResolutionFailure(string)

    Reports a type resolution failure using Unity's Debug.LogError for console visibility.

    Declaration
    protected override void ReportTypeResolutionFailure(string diagnostics)
    Parameters
    Type Name Description
    string diagnostics

    The diagnostic information about the failure.

    ShouldCreateInstanceOnSpecialContext(Type)

    Always returns true in Unity runtime. All instance creation is dispatched to the main thread when a dispatcher is available, because Unity object construction requires the main thread.

    Declaration
    protected override bool ShouldCreateInstanceOnSpecialContext(Type type)
    Parameters
    Type Name Description
    Type type
    Returns
    Type Description
    bool

    ShouldInvokeOnSpecialContext(MethodInfo, Type)

    Always returns true in Unity runtime. All reflected method invocations are dispatched to the main thread when a dispatcher is available. This conservative policy is necessary because methods may use Unity APIs internally without exposing Unity types in their signatures.

    Declaration
    protected override bool ShouldInvokeOnSpecialContext(MethodInfo method, Type targetType)
    Parameters
    Type Name Description
    MethodInfo method
    Type targetType
    Returns
    Type Description
    bool
    In this article
    © 2026 Serenity. All Rights Reserved