callOnCompletes() публичный Метод

public callOnCompletes ( ) : void
Результат void
Пример #1
0
        public override void OnPointerClick(PointerEventData eventData)
        {
            switch (eventData.button)
            {
            case PointerEventData.InputButton.Left:
                callback?.Invoke();
                break;

            case PointerEventData.InputButton.Right:
                if (leanTween != null)
                {
                    leanTween.callOnCompletes();
                    LeanTween.cancel(leanTween.uniqueId);
                }
                else
                {
                    Destroy(gameObject);
                }
                break;

            case PointerEventData.InputButton.Middle:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        public void Blend(AnimationScriptPlayable playable, float duration, AnimationCurve transitionCurve)
        {
            if (tweening && lastTween != null)
            {
                lastTween.callOnCompletes();
                lastTween.setOnUpdate((float value) => { });
                lastTween.setOnComplete(() => { });
                // LeanTween.pause(lastTween.id);
            }

            // tweenPlayable = AnimatorControllerPlayable.Create(playableGraph, ac);
            tweenPlayable = playable;
            mixerPlayable = AnimationMixerPlayable.Create(playableGraph, 2);

            mixerPlayable.ConnectInput(0, activePlayable, 0);
            mixerPlayable.ConnectInput(1, tweenPlayable, 0);

            // Plays the Graph.
            mixerPlayable.SetInputWeight(0, 1);
            playableOutput.SetSourcePlayable(mixerPlayable);

            lastTween = LeanTween
                        .value(playerController.gameObject, 0f, 1f, duration)
                        .setEase(transitionCurve)
                        .setOnUpdate((float value) =>
            {
                mixerPlayable.SetInputWeight(0, 1f - value);
                mixerPlayable.SetInputWeight(1, value);
            })
                        .setOnComplete(() =>
            {
                tweening = false;

                playableGraph.Disconnect(mixerPlayable, 0);
                playableGraph.Disconnect(mixerPlayable, 1);
                playableOutput.SetSourcePlayable(tweenPlayable);
                var prevActive = activePlayable;
                activePlayable = tweenPlayable;
                // prevActive.Destroy();
                mixerPlayable.Destroy();
            });

            tweening = true;
        }
Пример #3
0
	public static void update() {
		if(frameRendered != Time.frameCount){ // make sure update is only called once per frame
			init();

			#if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5
			dtEstimated = Time.realtimeSinceStartup - previousRealTime;
			if(dtEstimated>0.2f) // a catch put in, when at the start sometimes this number can grow unrealistically large
			dtEstimated = 0.2f;
			previousRealTime = Time.realtimeSinceStartup;
			#else

			dtEstimated = dtEstimated<0f ? 0f : dtEstimated = Time.unscaledDeltaTime;

			//		Debug.Log("Time.unscaledDeltaTime:"+Time.unscaledDeltaTime);
			#endif

			dtActual = Time.deltaTime;
			maxTweenReached = 0;
			finishedCnt = 0;
			// if(tweenMaxSearch>1500)
			//			 Debug.Log("tweenMaxSearch:"+tweenMaxSearch +" maxTweens:"+maxTweens);
			for( int i = 0; i <= tweenMaxSearch && i < maxTweens; i++){
				tween = tweens[i];
//				if(i==0 && tweens[i].toggle)
//					Debug.Log("tweens["+i+"]"+tweens[i]);
				if(tween.toggle){
					maxTweenReached = i;

					if (tween.updateInternal()) { // returns true if the tween is finished with it's loop
						tweensFinished[finishedCnt] = i;
						finishedCnt++;
					}
				}
			}

			// Debug.Log("maxTweenReached:"+maxTweenReached);
			tweenMaxSearch = maxTweenReached;
			frameRendered = Time.frameCount;

			for(int i = 0; i < finishedCnt; i++){
				j = tweensFinished[i];
				tween = tweens[ j ];
				//				Debug.Log("removing tween:"+tween);
				removeTween(j);
				if(tween.hasExtraOnCompletes && tween.trans!=null)
					tween.callOnCompletes();
			}

		}
	}
Пример #4
0
        public void TransitionToState(AnimationStateNode newState, float transitionTime, AnimationCurve transitionCurve)
        {
            lock (transitioningLock)
            {
                if (transitioning)
                {
                    transitionTween.callOnCompletes();
                    // transitionTween.setOnUpdate((float value) => { }).setOnComplete(() => { });
                    LeanTween.cancel(transitionTween.id);
                }
            }

            mixerRunner.Output.DisconnectInput(0);
            mixerRunner.Output.DisconnectInput(1);
            // if (!mixerPlayable.GetInput(0).IsNull()) mixerPlayable.DisconnectInput(0);
            // if (!mixerPlayable.GetInput(1).IsNull()) mixerPlayable.DisconnectInput(1);

            activeState     = nextActiveState;
            nextActiveState = newState;

            // Debug.Log($"Transition from {activeState?.name} to {nextActiveState?.name}, {newState.Output.IsValid()}, {newState.Output.GetInputCount()}");

            if (nextActiveState)
            {
                mixerRunner.Output.ConnectInput(0, nextActiveState.Output, 0);
            }
            else
            {
                mixerRunner.Output.ConnectInput(0, defaultPlayable, 0);
            }

            if (activeState)
            {
                mixerRunner.Output.ConnectInput(1, activeState.Output, 0);
            }

            mixerRunner.Output.SetInputWeight(0, 1f);
            mixerRunner.Output.SetInputWeight(1, 1f);

            if (nextActiveState != null)
            {
                transitioning = true;
                mixerRunner.SetBlendFromLastPosition(true);

                transitionTween =
                    LeanTween
                    .value(sharedData.Animatable.RootTransform.gameObject, 0f, 1f, transitionTime)
                    .setEase(transitionCurve)
                    .setOnStart(() =>
                {
                    // transitioning = true;
                    // mixerRunner.SetBlendFromLastPosition(true);
                    //Debug.Log($"Start tween from {activeState?.name} to {nextActiveState?.name}");
                })
                    .setOnUpdate((float value) =>
                {
                    mixerRunner.Factor = value;
                    //Debug.Log($"Update tween value {mixerRunner.Factor}");
                })
                    .setOnComplete(() =>
                {
                    lock (transitioningLock)
                    {
                        transitioning = false;
                    }
                    mixerRunner.SetBlendFromLastPosition(false);
                    //Debug.Log($"Complete tween from {activeState?.name} to {nextActiveState?.name}");
                });
            }

            // sharedData.Animatable.playableOutput.SetSourcePlayable(newState.Output);

            // mixerRunner.Factor = 0.0f;
        }