Example #1
0
 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));
 }
Example #2
0
 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);
 }
Example #3
0
        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();
                        }

                    }
                }

            }

        }
Example #4
0
        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 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);
     }
 }
Example #6
0
    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;

    }
 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 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);
        }

    }
Example #10
0
        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;
        }
	public LTDescr setLoopPingPong(int loops)
	{
		this.loopType = LeanTweenType.pingPong;
		this.loopCount = loops == -1 ? loops : loops * 2;
		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;
		}
		if (this.type == TweenAction.CALLBACK || this.type == TweenAction.CALLBACK_COLOR)
		{
			this.setOnCompleteOnRepeat(true);
		}
		return this;
	}
Example #13
0
    /// <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)");
        }

    }
Example #14
0
    /// <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;
    }
Example #15
0
 /**
 * 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;
 }
Example #16
0
 /**
 * 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;
 }
Example #17
0
 /**
 * 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;
 }
Example #18
0
 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++;
 }
Example #19
0
 /**
 * 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;
 }
Example #20
0
    /// <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));
    }
Example #21
0
 /**
 * 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;
 }
Example #22
0
 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);
 }
Example #23
0
 public LTDescr setLoopType( LeanTweenType loopType )
 {
     this.loopType = loopType;
     return this;
 }
Example #24
0
    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;
        }


    }
Example #25
0
    /// <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;
    }
Example #26
0
	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;
	}
Example #27
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);
     }
 }
Example #28
0
 public FageUITransition()
 {
     posX = posY = posZ = 0f;
     rotX = rotY = rotZ = 1f;
     scaleX = scaleY = scaleZ = 1f;
     time = delay = 0f;
     ease = LeanTweenType.linear;
 }
Example #29
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);
     }
 }
	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;
	}