private void Set(EventDelegate.Callback call) { if (call == null || !EventDelegate.IsValid(call)) { this.mTarget = null; this.mMethodName = null; this.mCachedCallback = null; this.mRawDelegate = false; } else { this.mTarget = (call.Target as MonoBehaviour); if (this.mTarget == null) { this.mRawDelegate = true; this.mCachedCallback = call; this.mMethodName = null; } else { this.mMethodName = EventDelegate.GetMethodName(call); this.mRawDelegate = false; } } }
public override bool Equals(object obj) { if (obj == null) { return(!this.isValid); } if (obj is EventDelegate.Callback) { EventDelegate.Callback callback = obj as EventDelegate.Callback; if (callback.Equals(this.mCachedCallback)) { return(true); } MonoBehaviour y = callback.Target as MonoBehaviour; return(this.mTarget == y && string.Equals(this.mMethodName, EventDelegate.GetMethodName(callback))); } else { if (obj is EventDelegate) { EventDelegate eventDelegate = obj as EventDelegate; return(this.mTarget == eventDelegate.mTarget && string.Equals(this.mMethodName, eventDelegate.mMethodName)); } return(false); } }
// Token: 0x06000391 RID: 913 RVA: 0x000213F0 File Offset: 0x0001F5F0 private void Set(EventDelegate.Callback call) { this.Clear(); if (call != null && EventDelegate.IsValid(call)) { this.mTarget = (call.Target as MonoBehaviour); if (this.mTarget == null) { this.mRawDelegate = true; this.mCachedCallback = call; this.mMethodName = null; return; } this.mMethodName = EventDelegate.GetMethodName(call); this.mRawDelegate = false; } }
private void Set(EventDelegate.Callback call) { this.Clear(); if (call != null && EventDelegate.IsValid(call)) { this.mTarget = (call.Target as MonoBehaviour); if (this.mTarget == (UnityEngine.Object)null) { this.mRawDelegate = true; this.mCachedCallback = call; this.mMethodName = (String)null; } else { this.mMethodName = EventDelegate.GetMethodName(call); this.mRawDelegate = false; } } }
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) { Debug.LogError(string.Concat(new object[] { "Could not find method '", this.mMethodName, "' on ", this.mTarget.GetType() }), this.mTarget); return; } if (this.mMethod.ReturnType != typeof(void)) { Debug.LogError(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++; } } }
private EventDelegate.Callback Get() { if (!this.mRawDelegate && (this.mCachedCallback == null || this.mCachedCallback.Target as MonoBehaviour != this.mTarget || EventDelegate.GetMethodName(this.mCachedCallback) != this.mMethodName)) { if (!(this.mTarget != null) || string.IsNullOrEmpty(this.mMethodName)) { return(null); } this.mCachedCallback = (EventDelegate.Callback)Delegate.CreateDelegate(typeof(EventDelegate.Callback), this.mTarget, this.mMethodName); } return(this.mCachedCallback); }
private void Cache() { this.mCached = true; if (this.mRawDelegate) { return; } if ((this.mCachedCallback == null || this.mCachedCallback.get_Target() as MonoBehaviour != this.mTarget || EventDelegate.GetMethodName(this.mCachedCallback) != this.mMethodName) && this.mTarget != null && !string.IsNullOrEmpty(this.mMethodName)) { Type type = this.mTarget.GetType(); try { IEnumerable <MethodInfo> runtimeMethods = type.GetRuntimeMethods(); using (IEnumerator <MethodInfo> enumerator = runtimeMethods.GetEnumerator()) { while (enumerator.MoveNext()) { MethodInfo current = enumerator.get_Current(); if (current.Name == this.mMethodName) { this.mMethod = current; break; } } } } catch (Exception ex) { Debug.LogError(string.Concat(new object[] { "Failed to bind ", type, ".", this.mMethodName, "\n", ex.get_Message() })); return; } if (this.mMethod == null) { Debug.LogError(string.Concat(new object[] { "Could not find method '", this.mMethodName, "' on ", this.mTarget.GetType() }), this.mTarget); return; } if (this.mMethod.ReturnType != typeof(void)) { Debug.LogError(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) this.mMethod.CreateDelegate(typeof(EventDelegate.Callback), this.mTarget); 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++; } } }
public unsafe static long $Invoke15(long instance, long *args) { return(GCHandledObjects.ObjectToGCHandle(EventDelegate.GetMethodName((EventDelegate.Callback)GCHandledObjects.GCHandleToObject(*args)))); }