예제 #1
0
    /// <summary>
    /// Creates a serializeable UnityFunc from the passed method on the targetObject
    /// </summary>
    public UnityFuncBase(Object targetObject, MethodInfo methodInfo)
    {
        _targetObject = targetObject;
        _methodName   = methodInfo.Name;
        _returnType   = new FuncSerializedType(methodInfo.ReturnType);

        ParameterInfo[] parameters = methodInfo.GetParameters();
        _arguments = new FuncSerializedTypeValue[parameters.Length];
        for (int paramCnt = 0; paramCnt < parameters.Length; paramCnt++)
        {
            _arguments[paramCnt] = new FuncSerializedType(parameters[paramCnt].ParameterType) as FuncSerializedTypeValue;
        }
    }
예제 #2
0
    /// <summary>
    /// Creates a serializeable UnityFunc from the passed delegate
    /// </summary>
    public UnityFuncBase(Delegate func)
    {
        if (func.Target == null || func.Method == null)
        {
            throw new ArgumentException("Func " + func + " is anonymous!");
        }

        _targetObject = (Object)func.Target;
        _methodName   = func.Method.Name;
        _returnType   = new FuncSerializedType(func.Method.ReturnType);

        ParameterInfo[] parameters = func.Method.GetParameters();
        _arguments = new FuncSerializedTypeValue[parameters.Length];
        for (int paramCnt = 0; paramCnt < parameters.Length; paramCnt++)
        {
            _arguments[paramCnt] = new FuncSerializedType(parameters[paramCnt].ParameterType) as FuncSerializedTypeValue;
        }
    }