public LTDescr Show(float time, LeanTweenType iType) { KCV.Utils.SoundUtils.PlaySE(SEFIleInfos.SE_941); _uiCommandLabel.transform.LTMoveLocalY(-125f, time).setEase(iType); _uiGlowLight.transform.LTValue(0f, 1f, 5f).setDelay(time).setEase(LeanTweenType.linear) .setOnUpdate(delegate(float x) { Rect uvRect = _uiGlowLight.uvRect; uvRect.x = x; _uiGlowLight.uvRect = uvRect; }) .setLoopClamp(); _uiGlowLight.transform.LTValue(1f, 0.3f, 1f).setEase(LeanTweenType.linear).setOnUpdate(delegate(float x) { _uiGlowLight.alpha = x; }) .setLoopPingPong(); return(_uiBackground.transform.LTValue(_uiBackground.width, 1150f, time).setEase(iType).setOnUpdate(delegate(float x) { int num = Convert.ToInt32(x); _uiBackground.height = num; _uiBGLight.height = num; _uiGlowLight.width = num; })); }
private void OnOutgoingBtnChange(LeanTweenType easeType) { //Moving all active incomingTrade values up for (int i = 0; i < activeIncomingTrades; i++) { Button btnToMove = _incomingTradeButtons[i]; float newYPos = -300 + _outgoingTradeHeightOffSet - elementHeight + (elementHeight * (activeIncomingTrades - i)) + (separationValue * (activeIncomingTrades - i)); LeanTween.moveLocalY(btnToMove.gameObject, newYPos, animationSpeed).setEase(easeType); if (i == 0) { LeanTween.moveLocalY(incomingTradesTitle.gameObject, newYPos + elementHeight, animationSpeed).setEase(easeType); } } //Moving all inactive incomingTrade values up for (int i = activeIncomingTrades; i < 4; i++) { Button btnToMove = _incomingTradeButtons[i]; float newYPos = -300 + _outgoingTradeHeightOffSet; LeanTween.moveLocalY(btnToMove.gameObject, newYPos, animationSpeed).setEase(moveOut); if (i == 0) { LeanTween.moveLocalY(incomingTradesTitle.gameObject, newYPos + elementHeight, animationSpeed).setEase(moveOut); } } }
public static void FitToDimensions(Vector2 dimensions, Vector2 margin, float time, LeanTweenType tweenType = LeanTweenType.easeInOutSine) { var zoom = CameraZoomToFit(dimensions, margin, Vector2.one); ZoomCamera(zoom, time, tweenType); }
public void MoveTo(GameObject go, Vector3 to, float t, LeanTweenType movCurve, bool arch, bool scale, System.Action callback) { //Debug.Log("Moving "+ go.name); float random = Random.Range(-0.1f, 0.1f); Vector3 dest = overlayCam.ScreenToWorldPoint(new Vector3(to.x, to.y, 10)); //Vector3 dest = GameObject.Find("BankCamera").GetComponent<Camera>().ScreenToWorldPoint(new Vector3(to.x, to.y, 10)); if (arch) { float climax = go.transform.position.y + 2 * Mathf.Sign(to.y - go.transform.position.y); LeanTween.moveY(go, climax, (t + random) / 2).setEase(LeanTweenType.easeOutCubic).setOnComplete(() => { LeanTween.moveY(go, dest.y, (t + random) / 2).setEase(LeanTweenType.easeInCubic); }); LeanTween.moveX(go, dest.x, t + random).setEase(movCurve); } else { LeanTween.move(go, dest, t + random).setEase(movCurve); } if (scale) { LeanTween.scale(go, Vector2.one * 0.8f, t * 0.1f).setEase(LeanTweenType.easeOutCubic).setOnComplete(() => { LeanTween.scale(go, Vector2.one * 0.35f, t * 0.9f).setEase(LeanTweenType.easeInCubic); }); } LeanTween.delayedCall(go, t + random, callback); timers[sprites.IndexOf(go)] = t + random + 0.1f; }
public void ChangeColor(Color color, float time, LeanTweenType leanTweenType = LeanTweenType.notUsed, Action onColorChangeComplete = null) { if (ColorLTDescr != null) { CancelColorLeanTween(); } if (currentColor == color) { return; } rect = GetComponent <RectTransform>(); ColorLTDescr = LeanTween.value(0, 1, time).setEase(leanTweenType).setOnUpdate(delegate(float value) { float r = Mapping(value, 0, 1, currentColor.r, color.r); float g = Mapping(value, 0, 1, currentColor.g, color.g); float b = Mapping(value, 0, 1, currentColor.b, color.b); float a = Mapping(value, 0, 1, currentColor.a, color.a); currentColor = image.color = new Color(r, g, b, a); }).setOnComplete(delegate() { currentColor = color; if (onColorChangeComplete != null) { onColorChangeComplete(); } ColorLTDescr = null; }); }
/// <summary> /// Fade out, move camera to view and then fade back in. /// </summary> public virtual void FadeToView(Camera camera, View view, float fadeDuration, bool fadeOut, Action fadeAction, LeanTweenType fadeType = LeanTweenType.easeInOutQuad, LeanTweenType sizeTweenType = LeanTweenType.easeInOutQuad, LeanTweenType posTweenType = LeanTweenType.easeInOutQuad, LeanTweenType rotTweenType = LeanTweenType.easeInOutQuad) { swipePanActive = false; fadeAlpha = 0f; float outDuration; float inDuration; if (fadeOut) { outDuration = fadeDuration / 2f; inDuration = fadeDuration / 2f; } else { outDuration = 0; inDuration = fadeDuration; } // Fade out Fade(1f, outDuration, delegate { // Snap to new view PanToPosition(camera, view.transform.position, view.transform.rotation, view.ViewSize, 0f, null, sizeTweenType, posTweenType, rotTweenType); // Fade in Fade(0f, inDuration, delegate { if (fadeAction != null) { fadeAction(); } }, fadeType); }, fadeType); }
public void PlayWithFadeInAt(InMusicGroup musicGroup, float targetVolume, float duration, double dspTime, LeanTweenType tweenType = LeanTweenType.easeInOutQuad) { var parent = GetParent(musicGroup); PlayAt(parent, dspTime); SetVolume(parent, 0); Fade(parent, targetVolume, duration, tweenType, Time.time + Mathf.Max((float)(dspTime - AudioSettings.dspTime), 0)); }
IEnumerator FadeRoutine(float timeToWait) { var time = HiddenSettings._.GetTime(timeToWait); yield return(new WaitForSeconds(time)); byte from = 255; float to = 0f; LeanTweenType leanTweenType = LeanTweenType.easeInBack; if (_isFadeIn) { from = 0; to = 1f; leanTweenType = LeanTweenType.easeOutBack; } var color = HiddenSettings._.RedColor; color.a = from; LoadingText.color = color; _fadeTextAnimationId = LeanTween.alphaText(LoadingText.gameObject.GetComponent <RectTransform>(), to, _timeBetweenFadings).id; LeanTween.descr(_fadeTextAnimationId.Value).setEase(leanTweenType); if (_isFadeIn) { LeanTween.descr(_fadeTextAnimationId.Value).setOnComplete(OnFadeInComplete); } else { LeanTween.descr(_fadeTextAnimationId.Value).setOnComplete(OnFadeOutComplete); } }
public void PlayWithFadeIn(InMusicGroup musicGroup, float targetVolume, float duration, LeanTweenType tweenType = LeanTweenType.easeInOutQuad) { var parent = GetParent(musicGroup); Play(parent); SetVolume(parent, 0); Fade(parent, targetVolume, duration, tweenType, Time.time); }
public InPlayer PlayConnectedTo(GameObject controllingObject, InAudioNode audioNode, GameObject attachedTo, AudioParameters audioParameters, float fade = 0f, LeanTweenType fadeType = LeanTweenType.notUsed) { if (audioNode.IsRootOrFolder) { Debug.LogWarning("InAudio: Cannot play \""+audioNode.GetName+"\" as it is a folder"); return null; } List<InstanceInfo> currentInstances = audioNode.CurrentInstances; if (!AllowedStealing(audioNode, currentInstances)) { return null; } var runtimePlayer = InAudioInstanceFinder.RuntimePlayerControllerPool.GetObject(); if (runtimePlayer == null) { Debug.LogWarning("InAudio: A pooled objected was not initialized. Try to restart play mode. If the problem persists, please submit a bug report."); } currentInstances.Add(new InstanceInfo(AudioSettings.dspTime, runtimePlayer)); runtimePlayer.transform.parent = attachedTo.transform; runtimePlayer.transform.localPosition = new Vector3(); Play(controllingObject, audioNode, runtimePlayer, fade, fadeType, audioParameters); return runtimePlayer; }
public void reset() { this.toggle = true; this.trans = null; this.passed = this.delay = this.lastVal = 0f; this.hasUpdateCallback = this.useEstimatedTime = this.useFrames = this.hasInitiliazed = this.onCompleteOnRepeat = this.destroyOnComplete = this.onCompleteOnStart = this.useManualTime = false; this.animationCurve = null; this.tweenType = LeanTweenType.linear; this.loopType = LeanTweenType.once; this.loopCount = 0; this.direction = this.directionLast = 1f; this.onUpdateFloat = null; this.onUpdateVector2 = null; this.onUpdateVector3 = null; this.onUpdateFloatObject = null; this.onUpdateVector3Object = null; this.onUpdateColor = null; this.onComplete = null; this.onCompleteObject = null; this.onCompleteParam = null; this.point = Vector3.zero; this.rectTransform = null; this.uiText = null; this.uiImage = null; this.sprites = null; global_counter++; if (global_counter > 0x8000) { global_counter = 0; } }
public void Init(string title, ActingType tType, float tweenTime, float delayTweenTime, bool isEnable, bool isAutoPlay, bool isLoop, LeanTweenType tweenType, LoopType loopType, int tweenCount, Vector4 toVec, Vector4 fromVec, Vector4 hideVec, System.Action <float> tweenTimeChanged, System.Action <float> delayTimeChanged, System.Action <bool> IsEnableChanged, System.Action <bool> autoPlayChanged, System.Action <bool> loopChanged, System.Action <LeanTweenType> tweenTypeChanged, System.Action <LoopType> loopTypeChanged, System.Action <int> countChanged, System.Action <Vector4> toChanged, System.Action <Vector4> fromChanged, System.Action <Vector4> hideChanged) { Title = title; TweenTime = tweenTime; TweenDelayTime = delayTweenTime; Enable = isEnable; AutoPlay = isAutoPlay; Loop = isLoop; CTweenType = tweenType; LoopType = loopType; TweenCount = tweenCount; To = toVec; From = fromVec; Hide = hideVec; m_tweenTimeChanged = tweenTimeChanged; m_tweenDelayTimeChanged = delayTimeChanged; m_autoPlayChanged = autoPlayChanged; m_loopChanged = loopChanged; m_tweenTypeChanged = tweenTypeChanged; m_loopTypeChanged = loopTypeChanged; m_tweenCountChanged = countChanged; m_toChanged = toChanged; m_fromChanged = fromChanged; m_hideChanged = hideChanged; m_enableChanged = IsEnableChanged; m_type = tType; }
private LTDescr Hide(float time, LeanTweenType iType) { return(panel.transform.LTValue(1f, 0f, time).setEase(iType).setOnUpdate(delegate(float x) { panel.alpha = x; })); }
public void StopAll(InAudioNode node, float fadeOutTime, LeanTweenType type) { if (node.IsRootOrFolder) { Debug.LogWarning("InAudio: Cannot stop audio on \"" + node.GetName + "\" as it is a folder"); } foreach (var audioNode in GOAudioNodes) { var infoList = audioNode.Value; if (infoList != null) { int count = infoList.InfoList.Count; for (int i = 0; i < count; i++) { if (infoList.InfoList[i].Node == node) { infoList.InfoList[i].Player.Stop(); } } } } }
public static LTDescr TweenRotateLocal(this Transform transform, Vector3 newRotation, float time = .3f, LeanTweenType easeType = LeanTweenType.easeOutExpo) { return(!transform ? null : LeanTween.rotateLocal(transform.gameObject, newRotation, time).setEase(easeType)); }
private IEnumerator StopAndMute(float fadeOutTime, LeanTweenType tweenType) { if (fadeOutTime < 0.1f) { float volume = 1.0f; while (volume > 0.01) { volume -= 13.0f * Time.deltaTime; for (int i = 0; i < audioSources.Count; ++i) { var source = audioSources[i]; if (audioSources[i] == null) { continue; } source.AudioSource.volume = volume; } yield return(null); } FinalCleanup(); } else { var tween = LeanTween.value(gameObject, (f, o) => (o as InPlayer).Volume = f, audioParameters.Volume * fadeVolume, 0.0f, fadeOutTime); tween.onUpdateParam = this; tween.tweenType = tweenType; tween.onComplete = FinalCleanup; } }
// reference:) IObservable <float> LeanTweenObservable(LeanTweenType easingType) { const float DefaultOvershoot = 1.70158f; const float DefaultPeriod = 0.3f; return(Observable.Create <float>(observer => { var cube = GameObject.CreatePrimitive(PrimitiveType.Cube); cube.name = "dummy"; cube.transform.position = new Vector3(0, 0, 0); cube.SetActive(false); //cube.move LeanTween.moveX(cube, 1.0f, 1.0f) .setOvershoot(DefaultOvershoot) .setPeriod(DefaultPeriod) .setOnUpdate(x => { observer.OnNext(x); }) .setOnComplete(() => { observer.OnCompleted(); }) .setEase(easingType); return Disposable.Empty; })); }
public void Hide(Action OnComplete = null) { if (isBusy) { return; } isBusy = true; LeanTweenType ease = PlatinioUI.GetEase(exitAnimation); //set initial pos switch (exitTo) { case PlatinioUI.Direction.BOTTOM: LeanTween.moveY(gameObject, -platinioUI.verticalOffset, entryAnimationTime).setEase(ease).setOnComplete(() => { if (OnComplete != null) { OnComplete(); } isBusy = false; gameObject.SetActive(false); }); break; case PlatinioUI.Direction.LEFT: LeanTween.moveX(gameObject, -platinioUI.horizontalOffset, entryAnimationTime).setEase(ease).setOnComplete(() => { isBusy = false; gameObject.SetActive(false); }); break; case PlatinioUI.Direction.RIGHT: LeanTween.moveX(gameObject, platinioUI.horizontalOffset, entryAnimationTime).setEase(ease).setOnComplete(() => { if (OnComplete != null) { OnComplete(); } isBusy = false; gameObject.SetActive(false); }); break; case PlatinioUI.Direction.UP: LeanTween.moveY(gameObject, platinioUI.verticalOffset, entryAnimationTime).setEase(ease).setOnComplete(() => { if (OnComplete != null) { OnComplete(); } isBusy = false; gameObject.SetActive(false); }); break; } }
/// <summary> /// Rotates the gameObject back and forth around the given axis. /// </summary> /// <param name="gameObject"></param> /// <param name="axis"></param> /// <param name="angle"></param> /// <param name="duration"></param> /// <param name="loops"></param> /// <param name="ease"></param> /// <param name="onComplete"></param> public static void Wobble( GameObject gameObject, Vector3 axis, float angle, float duration, int loops, LeanTweenType ease = LeanTweenType.linear, Action onComplete = null) { loops = Mathf.Clamp(loops, 0, int.MaxValue); var wobbleDuration = duration / (loops + 1); var halfWobbleDuration = wobbleDuration * 0.5f; var halfAngle = angle * 0.5f; void Start() { WobbleStart(); } void WobbleStart() { LeanTween.rotateAroundLocal(gameObject, axis, -halfAngle, halfWobbleDuration) .setEase(ease) .setOnComplete(() => { if (loops == 0) { WobbleEnd(); } else { WobbleLoop(); } }); } void WobbleLoop() { LeanTween.rotateAroundLocal(gameObject, axis, angle, halfWobbleDuration) .setLoopPingPong(loops) .setEase(ease) .setOnComplete(WobbleEnd); } void WobbleEnd() { LeanTween.rotateAroundLocal(gameObject, axis, halfAngle, halfWobbleDuration) .setEase(ease) .setOnComplete(OnComplete); } void OnComplete() { onComplete?.Invoke(); } Start(); }
public static LTDescr TweenScale(this Transform transform, Vector3 fromScale, Vector3 newScale, float time = .3f, LeanTweenType easeType = LeanTweenType.easeOutExpo) { return(!transform ? null : LeanTween.scale(transform.gameObject, newScale, time).setEase(easeType).setFrom(fromScale)); }
static int IntToEnum(IntPtr L) { int arg0 = (int)LuaDLL.lua_tonumber(L, 1); LeanTweenType o = (LeanTweenType)arg0; ToLua.Push(L, o); return(1); }
public static void Fade(RectTransform trs,float alpha,float time,LeanTweenType type=LeanTweenType.linear,Action complete = null) { LTDescr d = LeanTween.alpha(trs, alpha, time).setEase(type); if (complete != null) { d.setOnComplete(complete); } }
public FageUITransition() { posX = posY = posZ = 0f; rotX = rotY = rotZ = 1f; scaleX = scaleY = scaleZ = 1f; time = delay = 0f; ease = LeanTweenType.linear; }
public void PlayWithFadeIn(InMusicGroup musicGroup, float duration, LeanTweenType tweenType = LeanTweenType.easeInOutQuad) { var parent = GetParent(musicGroup); SetVolume(parent, 0); Play(parent); Fade(parent, 1f, duration, tweenType, Time.time); }
private void Move(Transform Locator, Vector3 target, LeanTweenType leanTweenType = LeanTweenType.notUsed, Action action = null) { LeanTween.moveLocal(Locator.gameObject, target, .5f).setOnComplete(delegate() { if (action != null) { action(); } }).setEase(leanTweenType); }
private void Start() { Ease = LeanTweenType.easeInOutSine; transform.localEulerAngles = -StartRotation; LeanTween.rotateLocal(gameObject, EndRotation, Time) .setDelay(Delay) .setEase(Ease); }
public void Scale(Vector2 initialScale, Vector2 finalScale, float scaleTime, LeanTweenType easeType = LeanTweenType.linear) { scaleTween.initialScale = initialScale; scaleTween.finalScale = finalScale; scaleTween.scaleTime = scaleTime; scaleTween.easeType = easeType; scaleTween.Execute(); }
public GeneralMoveState(EnemyStateMachine stateMachine, Vector2 startPos, Vector2 endPos, float moveTime, LeanTweenType easeType) : base(stateMachine.enemy) { this.startPos = startPos; this.endPos = endPos; this.moveTime = moveTime; this.easeType = easeType; isFinished = false; }
public EnemyRotateTo(RotateToData _data) { tweenDesc = null; angle = _data.angle; time = _data.time; isAiming = _data.aim; ease = (LeanTweenType)Enum.Parse(typeof(LeanTweenType), _data.ease); direction = _data.direction; }
public static LTDescr TweenAlpha(this CanvasGroup canvasGroup, float newAlpha, float time = .3f, LeanTweenType easeType = LeanTweenType.linear) { return(!canvasGroup ? null : LeanTween.value(canvasGroup.gameObject, value => { canvasGroup.alpha = value; }, canvasGroup.alpha, newAlpha, time) .setEase(easeType)); }
public LTDescr setRepeat(int repeat) { loopCount = repeat; if ((repeat > 1 && loopType == LeanTweenType.once) || (repeat < 0 && loopType == LeanTweenType.once)) { loopType = LeanTweenType.clamp; } return(this); }
void ScaleUp(Transform Locator, Vector3 scale, LeanTweenType leanTweenType = LeanTweenType.notUsed, float time = .5f, Action action = null) { LeanTween.scale(Locator.gameObject, scale, time).setOnComplete(delegate() { if (action != null) { action(); } }).setEase(leanTweenType); }
public LTDescr setLoopPingPong() { this.loopType = LeanTweenType.pingPong; if (this.loopCount == 0) { this.loopCount = -1; } return(this); }
public LTDescr setLoopClamp() { this.loopType = LeanTweenType.clamp; if (this.loopCount == 0) { this.loopCount = -1; } return(this); }
public void FadeIn(float dur, LeanTweenType trans = LeanTweenType.easeInCubic, Action callback = null) { if (m_ease != null && LeanTween.isTweening(m_ease.uniqueId)) LeanTween.cancel(m_ease.uniqueId); m_ease = LeanTween.value(gameObject, OnFade, m_blackScreenAlpha, 0, dur).setEase(trans); m_ease.onComplete = callback; }
private IDictionary <string, Vector3> destDict = new Dictionary <string, Vector3>(); // a dest mean a destination, a marked point that will be the destination #endregion #region Methods // constructor public TwnVector(GameObject __target, Vector3 __origin, string __key, Vector3 __vector2, float __time, LeanTweenType __tweenType, bool __ignoreTimeScale = true, CallBack __callBack = null) { callBack = __callBack; ignoreTimeScale = __ignoreTimeScale; target = __target; time = __time; tweenType = __tweenType; AddDest("origin", __origin); AddDest(__key, __vector2); }
private IEnumerator GroundHitAnimation(float delay, LeanTweenType easeType) { _character.model.gameObject.ScaleTween(new Vector3(1.5f, 0.6f, 1), delay, easeType); yield return(new WaitForSeconds(delay)); _character.model.gameObject.ScaleTween(new Vector3(1, 1.3f, 1), delay, easeType); yield return(new WaitForSeconds(delay)); _character.model.gameObject.ScaleTween(Vector3.one, delay, easeType); }
public static void MoveActionY(CanvasGroup cg, float to, float alpha, float time, float alphatime = -1, LeanTweenType type = LeanTweenType.linear, Action complete = null) { LTRect cgrect = new LTRect(); cgrect.alpha = cg.alpha; alphatime = (alphatime < 0) ? to : alphatime; LeanTween.alpha(cgrect, alpha, time).setEase(type); LTDescr d = LeanTween.moveLocalY(cg.transform.gameObject, to, time).setEase(type); d.setOnUpdate((float f) => { UpdateAlpha(cg, cgrect.alpha); }); if (complete != null) { d.setOnComplete(complete); } }
public static void Alpha(CanvasGroup cg,float alpha,float time,LeanTweenType type=LeanTweenType.linear,Action complete = null) { LTRect cgrect = new LTRect(); cgrect.alpha = cg.alpha; LTDescr d = LeanTween.alpha(cgrect, alpha, time).setEase(type); d.setOnUpdate((float f) => { UpdateAlpha(cg, cgrect.alpha); }); if (complete != null) { d.setOnComplete(complete); } }
public InPlayer PlayAtPosition(GameObject controllingObject, InAudioNode audioNode, Vector3 position, AudioParameters audioParameters, float fade = 0f, LeanTweenType fadeType = LeanTweenType.notUsed) { if (audioNode.IsRootOrFolder) { Debug.LogWarning("InAudio: Cannot play \"" + audioNode.GetName + "\" as it is a folder"); return null; } List<InstanceInfo> currentInstances = audioNode.CurrentInstances; if (!AllowedStealing(audioNode, currentInstances)) return null; var runtimePlayer = InAudioInstanceFinder.RuntimePlayerControllerPool.GetObject(); runtimePlayer.transform.position = position; currentInstances.Add(new InstanceInfo(AudioSettings.dspTime, runtimePlayer)); Play(controllingObject, audioNode, runtimePlayer, fade, fadeType, audioParameters); return runtimePlayer; }
/// <summary> /// Play an audio node directly with a fade, following a game object and persists even if the GO is destroyed. /// </summary> /// <param name="gameObject">The game object to be controlled by and follow</param> /// <param name="audioNode">The node to play</param> /// <param name="fadeTime">How long it should take to fade in from 0 to 1 in volume</param> /// <param name="tweeenType">The curve of fading</param> /// <param name="parameters">Parameters to set initial values directly</param> /// <returns>A controller for the playing node</returns> public static InPlayer PlayFollowing(GameObject gameObject, InAudioNode audioNode, float fadeTime, LeanTweenType tweeenType, AudioParameters parameters = null) { if (instance == null || audioNode == null || audioNode.IsRootOrFolder || gameObject == null) { InDebug.MissingArguments("PlayFollowing (tween)", gameObject, audioNode); return null; } InPlayer player = instance._inAudioEventWorker.PlayFollowing(gameObject, audioNode, parameters); player.Volume = 0.0f; LTDescr tweever = LeanTween.value(gameObject, (f, o) => { (o as InPlayer).Volume = f; }, 0.0f, 1f, fadeTime); tweever.onUpdateParam = player; tweever.tweenType = tweeenType; return player; }
public LTDescr setLoopType( LeanTweenType loopType ) { this.loopType = loopType; return this; }
/** * Set the tween to repeat a number of times. * @method setRepeat * @param {int} repeatNum:int the number of times to repeat the tween. -1 to repeat infinite times * @return {LTDescr} LTDescr an object that distinguishes the tween * @example * LeanTween.moveX(gameObject, 5f, 2.0f ).setRepeat( 10 ).setLoopPingPong(); */ public LTDescr setRepeat( int repeat ) { this.loopCount = repeat; if((repeat>1 && this.loopType == LeanTweenType.once) || (repeat < 0 && this.loopType == LeanTweenType.once)){ this.loopType = LeanTweenType.clamp; } return this; }
/** * No looping involved, just run once (the default) * @method setLoopOnce * @return {LTDescr} LTDescr an object that distinguishes the tween * @example * LeanTween.moveX(gameObject, 5f, 2.0f ).setLoopOnce(); */ public LTDescr setLoopOnce() { this.loopType = LeanTweenType.once; return this; }
/** * When the animation gets to the end it then tweens back to where it started (and on, and on) * @method setLoopPingPong * @return {LTDescr} LTDescr an object that distinguishes the tween * @example * LeanTween.moveX(gameObject, 5f, 2.0f ).setRepeat(2).setLoopPingPong(); */ public LTDescr setLoopPingPong() { this.loopType = LeanTweenType.pingPong; if(this.loopCount==0) this.loopCount = -1; return this; }
/** * Set the type of easing used for the tween. <br> * <ul><li><a href="LeanTweenType.html">List of all the ease types</a>.</li> * <li><a href="http://www.robertpenner.com/easing/easing_demo.html">This page helps visualize the different easing equations</a></li> * </ul> * * @method setEase * @param {LeanTweenType} easeType:LeanTweenType the easing type to use * @return {LTDescr} LTDescr an object that distinguishes the tween * @example * LeanTween.moveX(gameObject, 5f, 2.0f ).setEase( LeanTweenType.easeInBounce ); */ public LTDescr setEase( LeanTweenType easeType ) { this.tweenType = easeType; return this; }
/** * When the animation gets to the end it starts back at where it began * @method setLoopClamp * @return {LTDescr} LTDescr an object that distinguishes the tween * @example * LeanTween.moveX(gameObject, 5f, 2.0f ).setRepeat(2).setLoopClamp(); */ public LTDescr setLoopClamp() { this.loopType = LeanTweenType.clamp; if(this.loopCount==0) this.loopCount = -1; return this; }
public LTDescr setLoopPingPong(int loops) { this.loopType = LeanTweenType.pingPong; this.loopCount = loops == -1 ? loops : loops * 2; return this; }
public void reset() { this.toggle = true; #if !UNITY_METRO this.optional = null; #endif this.passed = this.delay = 0.0f; this.useEstimatedTime = this.useFrames = this.hasInitiliazed = this.onCompleteOnRepeat = this.destroyOnComplete = false; this.animationCurve = null; this.tweenType = LeanTweenType.linear; this.loopType = LeanTweenType.once; this.loopCount = 0; this.direction = this.lastVal = 1.0f; this.onUpdateFloat = null; this.onUpdateVector3 = null; this.onUpdateFloatObject = null; this.onUpdateVector3Object = null; this.onComplete = null; this.onCompleteObject = null; this.onCompleteParam = null; this.point = Vector3.zero; global_counter++; }
/// <summary> /// Stop all sounds playing with fade out time /// </summary> /// <param name="gameObject"></param> /// <param name="fadeOut">Time to fade out</param> /// <param name="fadeType">Fade type</param> public static void StopAll(float fadeOut, LeanTweenType fadeType) { if (instance != null) { instance._inAudioEventWorker.StopAll(fadeOut, fadeType); } else { InDebug.InstanceMissing("StopAll (fade)"); } }
/// <summary> /// Internal InAudio play method. Please use InAudio.Play(...) to play audio /// </summary> public void _internalPlay(InAudioNode node, GameObject controllingObject, RuntimeInfo playingInfo, float fade, LeanTweenType fadeType, AudioParameters parameters) { if (node.IsRootOrFolder) { Debug.LogWarning("InAudio: Cannot play Folder node \"" + node.Name + "\""); return; } if (audioParameters == null) { audioParameters = new AudioParameters(); } if (parameters != null) { audioParameters.CopyFrom(parameters); } else { audioParameters.Reset(); } dspPool = InAudioInstanceFinder.DSPTimePool; breakLoop = false; controlling = controllingObject; ParentBeforeFolder = TreeWalker.FindParentBeforeFolder(node); ParentFolder = ParentBeforeFolder._parent._nodeData as InFolderData; folderVolume = 1.0f; if (ParentFolder != null) { folderVolume = ParentFolder.runtimeVolume; ParentFolder.runtimePlayers.Add(this); } //This is to queue the next playing node, as the first clip will not yield a waitforseconds //firstClip = true; runtimeInfo = playingInfo; PlayingNode = node; DSPTime time = dspPool.GetObject(); time.CurrentEndTime = AudioSettings.dspTime; isActive = true; fadeVolume = 1f; _spread = 0.0f; if (fade > 0) { LTDescr tweever = LeanTween.value(controllingObject, f => { fadeVolume = f; SetFadeVolume(f); }, 0f, 1f, fade); tweever.tweenType = fadeType; fadeVolume = 0; SetFadeVolume(0); } StartCoroutine(StartPlay(node, time)); }
/// <summary> /// Play an audio node in world space with a custom fade, attached to another game object /// </summary> /// <param name="gameObject">The game object to attach to and be controlled by</param> /// <param name="audioNode">The node to play</param> /// <param name="position">The world position to play at</param> /// <param name="fadeTime">How long it should take to fade in from 0 to 1 in volume</param> /// <param name="tweeenType">The curve of fading</param> /// <param name="startVolume">The starting volume</param> /// <param name="endVolume">The end volume</param> /// <param name="parameters">Parameters to set initial values directly</param> /// <returns>A controller for the playing node</returns> public static InPlayer PlayAtPosition(GameObject gameObject, InAudioNode audioNode, Vector3 position, float fadeTime, LeanTweenType tweeenType, float startVolume, float endVolume, AudioParameters parameters = null) { if (instance == null || audioNode == null || audioNode.IsRootOrFolder) { InDebug.MissingArguments("PlayAtPosition (tween specific)", gameObject, audioNode); return null; } InPlayer player = instance._inAudioEventWorker.PlayAtPosition(gameObject, audioNode, position, parameters); player.Volume = startVolume; LTDescr tweever = LeanTween.value(gameObject, (f, o) => { (o as InPlayer).Volume = f; }, startVolume, endVolume, fadeTime); tweever.onUpdateParam = player; tweever.tweenType = tweeenType; return player; }
public void _internalPlayFollowing(InAudioNode node, GameObject controllingObject, RuntimeInfo playingInfo, float fade, LeanTweenType fadeType, AudioParameters parameters) { this.toFollow = controllingObject.transform; internalUpdate(); _internalPlay(node, controllingObject, playingInfo, fade, fadeType, parameters); }
private IEnumerator StopAndMute(float fadeOutTime, LeanTweenType tweenType) { if (fadeOutTime < 0.1f) { float volume = 1.0f; while (volume > 0.01) { volume -= 13.0f*Time.deltaTime; for (int i = 0; i < audioSources.Count; ++i) { var source = audioSources[i]; if (audioSources[i] == null) continue; source.AudioSource.volume = volume; } yield return null; } FinalCleanup(); } else { var tween = LeanTween.value(gameObject, (f, o) => (o as InPlayer).Volume = f, audioParameters.Volume*fadeVolume, 0.0f, fadeOutTime); tween.onUpdateParam = this; tween.tweenType = tweenType; tween.onComplete = FinalCleanup; } }
public void reset(){ this.toggle = true; #if LEANTWEEN_1 this.optional = null; #endif this.trans = null; this.passed = this.delay = this.lastVal = 0.0f; this.hasUpdateCallback = this.useEstimatedTime = this.useFrames = this.hasInitiliazed = this.onCompleteOnRepeat = this.destroyOnComplete = this.onCompleteOnStart = this.useManualTime = false; this.animationCurve = null; this.tweenType = LeanTweenType.linear; this.loopType = LeanTweenType.once; this.loopCount = 0; this.direction = this.directionLast = 1.0f; this.onUpdateFloat = null; this.onUpdateVector2 = null; this.onUpdateVector3 = null; this.onUpdateFloatObject = null; this.onUpdateVector3Object = null; this.onUpdateColor = null; this.onComplete = null; this.onCompleteObject = null; this.onCompleteParam = null; this.point = Vector3.zero; #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 this.rectTransform = null; this.uiText = null; this.uiImage = null; this.sprites = null; #endif global_counter++; if(global_counter>0x8000) global_counter = 0; }
/// <summary> /// Stop all sound effects /// </summary> /// <param name="gameObject"></param> public static void StopAllOfNode(InAudioNode audioNode, float fadeOutDuration, LeanTweenType leanTweenType = LeanTweenType.easeInOutQuad) { if (instance != null) instance._inAudioEventWorker.StopAll(0, leanTweenType); else { InDebug.MissingArgumentsForNode("StopAllOfNode", audioNode); } }
public void reset() { this.toggle = true; #if LEANTWEEN_1 this.optional = null; #endif this.trans = null; this.passed = this.delay = this.lastVal = 0.0f; this.hasUpdateCallback = this.useEstimatedTime = this.useFrames = this.hasInitiliazed = this.onCompleteOnRepeat = this.destroyOnComplete = this.onCompleteOnStart = this.useManualTime = false; this.animationCurve = null; this.tweenType = LeanTweenType.linear; this.loopType = LeanTweenType.once; this.loopCount = 0; this.direction = this.directionLast = this.overshoot = 1.0f; this.period = 0.3f; this.point = Vector3.zero; cleanup(); global_counter++; if (global_counter > 0x8000) global_counter = 0; }
/// <summary> /// Stop all sounds playing on this game object with fade out time /// </summary> /// <param name="gameObject"></param> /// <param name="fadeOut">Time to fade out</param> /// <param name="fadeType">Fade type</param> public static void StopAll(GameObject gameObject, float fadeOut, LeanTweenType fadeType) { if (instance != null && gameObject != null) { instance._inAudioEventWorker.StopAll(gameObject, 0, LeanTweenType.notUsed); } else { InDebug.MissingArguments("StopAll (on GameObject)", gameObject, null); } }
/** * Set the tween to repeat a number of times. * @method setRepeat * @param {int} repeatNum:int the number of times to repeat the tween. -1 to repeat infinite times * @return {LTDescr} LTDescr an object that distinguishes the tween * @example * LeanTween.moveX(gameObject, 5f, 2.0f ).setRepeat( 10 ).setLoopPingPong(); */ public LTDescr setRepeat(int repeat) { this.loopCount = repeat; if ((repeat > 1 && this.loopType == LeanTweenType.once) || (repeat < 0 && this.loopType == LeanTweenType.once)) { this.loopType = LeanTweenType.clamp; } if (this.type == TweenAction.CALLBACK || this.type == TweenAction.CALLBACK_COLOR) { this.setOnCompleteOnRepeat(true); } return this; }