EventDelegate.Execute C# (CSharp) Method

Execute() public method

Execute the delegate, if possible. This will only be used when the application is playing in order to prevent unintentional state changes.
public Execute ( ) : bool
return bool
	public bool Execute ()
	{
		Callback call = Get();

		if (call != null)
		{
#if UNITY_EDITOR
			if (Application.isPlaying)
			{
				call();
			}
			else if (call.Target != null)
			{
				System.Type type = call.Target.GetType();
				object[] objs = type.GetCustomAttributes(typeof(ExecuteInEditMode), true);
				if (objs != null && objs.Length > 0) call();
			}
#else
			call();
#endif
			return true;
		}
#if !REFLECTION_SUPPORT
		if (isValid)
		{
			mTarget.SendMessage(mMethodName, SendMessageOptions.DontRequireReceiver);
			return true;
		}
#endif
		return false;
	}

Same methods

EventDelegate::Execute ( List list ) : void

Usage Example

Beispiel #1
0
    private void Update()
    {
        float num  = (!this.ignoreTimeScale) ? Time.deltaTime : RealTime.deltaTime;
        float num2 = (!this.ignoreTimeScale) ? Time.time : RealTime.time;

        if (!this.mStarted)
        {
            this.mStarted   = true;
            this.mStartTime = num2 + this.delay;
        }
        if (num2 < this.mStartTime)
        {
            return;
        }
        this.mFactor += this.amountPerDelta * num;
        if (this.style == UITweener.Style.Loop)
        {
            if (this.mFactor > 1f)
            {
                this.mFactor -= Mathf.Floor(this.mFactor);
            }
        }
        else if (this.style == UITweener.Style.PingPong)
        {
            if (this.mFactor > 1f)
            {
                this.mFactor         = 1f - (this.mFactor - Mathf.Floor(this.mFactor));
                this.mAmountPerDelta = -this.mAmountPerDelta;
            }
            else if (this.mFactor < 0f)
            {
                this.mFactor         = -this.mFactor;
                this.mFactor        -= Mathf.Floor(this.mFactor);
                this.mAmountPerDelta = -this.mAmountPerDelta;
            }
        }
        if (this.style == UITweener.Style.Once && (this.duration == 0f || this.mFactor > 1f || this.mFactor < 0f))
        {
            this.mFactor = Mathf.Clamp01(this.mFactor);
            this.Sample(this.mFactor, true);
            if (UITweener.current == null)
            {
                UITweener uITweener = UITweener.current;
                UITweener.current = this;
                if (this.onFinished != null)
                {
                    this.mTemp      = this.onFinished;
                    this.onFinished = new List <EventDelegate>();
                    EventDelegate.Execute(this.mTemp);
                    for (int i = 0; i < this.mTemp.Count; i++)
                    {
                        EventDelegate eventDelegate = this.mTemp[i];
                        if (eventDelegate != null && !eventDelegate.oneShot)
                        {
                            EventDelegate.Add(this.onFinished, eventDelegate, eventDelegate.oneShot);
                        }
                    }
                    this.mTemp = null;
                }
                if (this.eventReceiver != null && !string.IsNullOrEmpty(this.callWhenFinished))
                {
                    this.eventReceiver.SendMessage(this.callWhenFinished, this, SendMessageOptions.DontRequireReceiver);
                }
                UITweener.current = uITweener;
            }
            if (this.duration == 0f || (this.mFactor == 1f && this.mAmountPerDelta > 0f) || (this.mFactor == 0f && this.mAmountPerDelta < 0f))
            {
                base.enabled = false;
            }
        }
        else
        {
            this.Sample(this.mFactor, false);
        }
    }
All Usage Examples Of EventDelegate::Execute