Ejemplo n.º 1
0
 private void Cache()
 {
     this.mCached = true;
     if (this.mRawDelegate)
     {
         return;
     }
     if ((this.mCachedCallback == null || this.mCachedCallback.Target as MonoBehaviour != this.mTarget || EventDelegate.GetMethodName(this.mCachedCallback) != this.mMethodName) && this.mTarget != null && !string.IsNullOrEmpty(this.mMethodName))
     {
         Type type = this.mTarget.GetType();
         this.mMethod = null;
         while (type != null)
         {
             try
             {
                 this.mMethod = type.GetMethod(this.mMethodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                 if (this.mMethod != null)
                 {
                     break;
                 }
             }
             catch (Exception)
             {
             }
             type = type.BaseType;
         }
         if (this.mMethod == null)
         {
             global::Debug.LogError(new object[]
             {
                 string.Concat(new object[]
                 {
                     "Could not find method '",
                     this.mMethodName,
                     "' on ",
                     this.mTarget.GetType()
                 }),
                 this.mTarget
             });
             return;
         }
         if (this.mMethod.ReturnType != typeof(void))
         {
             global::Debug.LogError(new object[]
             {
                 string.Concat(new object[]
                 {
                     this.mTarget.GetType(),
                     ".",
                     this.mMethodName,
                     " must have a 'void' return type."
                 }),
                 this.mTarget
             });
             return;
         }
         this.mParameterInfos = this.mMethod.GetParameters();
         if (this.mParameterInfos.Length == 0)
         {
             this.mCachedCallback = (EventDelegate.Callback)Delegate.CreateDelegate(typeof(EventDelegate.Callback), this.mTarget, this.mMethodName);
             this.mArgs = null;
             this.mParameters = null;
             return;
         }
         this.mCachedCallback = null;
         if (this.mParameters == null || this.mParameters.Length != this.mParameterInfos.Length)
         {
             this.mParameters = new EventDelegate.Parameter[this.mParameterInfos.Length];
             int i = 0;
             int num = this.mParameters.Length;
             while (i < num)
             {
                 this.mParameters[i] = new EventDelegate.Parameter();
                 i++;
             }
         }
         int j = 0;
         int num2 = this.mParameters.Length;
         while (j < num2)
         {
             this.mParameters[j].expectedType = this.mParameterInfos[j].ParameterType;
             j++;
         }
     }
 }
Ejemplo n.º 2
0
 public void Clear()
 {
     this.mTarget = null;
     this.mMethodName = null;
     this.mRawDelegate = false;
     this.mCachedCallback = null;
     this.mParameters = null;
     this.mCached = false;
     this.mMethod = null;
     this.mParameterInfos = null;
     this.mArgs = null;
 }