示例#1
0
        /**
         * <summary>Creates a new instance of the 'Sound: Play' Action, set to stop a sound</summary>
         * <param name = "sound">The Sound to stop</param>
         * <param name = "fadeDuration">If non-negative, the duration of the fade-out effect</param>
         * <param name = "waitUntilFinish">If True, then the Action will wait until the sound has finished playing</param>
         * <returns>The generated Action</returns>
         */
        public static ActionSound CreateNew_Stop(Sound sound, float fadeDuration = 0f, bool waitUntilFinish = false)
        {
            ActionSound newAction = (ActionSound)CreateInstance <ActionSound>();

            newAction.soundAction = (fadeDuration > 0f) ? SoundAction.FadeOut : SoundAction.Stop;
            newAction.willWait    = waitUntilFinish;
            return(newAction);
        }
示例#2
0
        /**
         * <summary>Creates a new instance of the 'Sound: Play' Action, set to play a new sound</summary>
         * <param name = "sound">The Sound to play from</param>
         * <param name = "newClip">If set, the clip to play</param>
         * <param name = "fadeDuration">If non-negative, the duration of the fade-in effect</param>
         * <param name = "doLoop">If True, the sound will loop</param>
         * <param name = "ignoreIfAlreadyPlaying">If True, nothing will happen if the Sound is already playing the chosen audio clip</param>
         * <param name = "waitUntilFinish">If True, then the Action will wait until the sound has finished playing</param>
         * <returns>The generated Action</returns>
         */
        public static ActionSound CreateNew_Play(Sound sound, AudioClip newClip, float fadeDuration = 0f, bool doLoop = false, bool ignoreIfAlreadyPlaying = true, bool waitUntilFinish = false)
        {
            ActionSound newAction = (ActionSound)CreateInstance <ActionSound>();

            newAction.soundAction     = (fadeDuration > 0f) ? SoundAction.FadeIn : SoundAction.Play;
            newAction.audioClip       = newClip;
            newAction.loop            = doLoop;
            newAction.ignoreIfPlaying = ignoreIfAlreadyPlaying;
            newAction.willWait        = waitUntilFinish;
            return(newAction);
        }