예제 #1
0
        public static IAudioStream Play(AudioClip clip,
                                        AudioSource source = null,
                                        float?volume       = null,
                                        IAudioGroup group  = null,
                                        string id          = null,
                                        bool?loop          = null,
                                        bool?mute          = null,
                                        bool?pause         = null,
                                        OverrideSettingsFlag?overrideGroupFlags = null,
                                        Action onComplete = null)
        {
            var builder = source ? GetBuilder(source) : GetBuilder();

            builder.SetClip(clip);

            if (group != null)
            {
                builder.SetGroup(group);
            }

            if (id != null)
            {
                builder.SetID(id);
            }

            if (loop.HasValue)
            {
                builder.SetLoop(loop.Value);
            }

            if (volume.HasValue)
            {
                builder.SetVolume(volume.Value);
            }

            if (mute.HasValue)
            {
                builder.SetMute(mute.Value);
            }

            if (pause.HasValue)
            {
                builder.SetPause(pause.Value);
            }

            if (overrideGroupFlags.HasValue)
            {
                builder.SetOverrideGroupFlags(overrideGroupFlags.Value);
            }

            if (onComplete != null)
            {
                builder.SetOnComplete(onComplete);
            }

            return(builder.Play());
        }
예제 #2
0
        private void SetGroup(IAudioGroup group)
        {
            if (_group != null)
            {
                _group.Settings.OnMute          -= OnMute;
                _group.Settings.OnPause         -= OnPause;
                _group.Settings.OnVolumeChanged -= OnVolumeChanged;

                (_group as AudioGroup).Remove(this);
            }

            if ((_group = group) != null)
            {
                (_group as AudioGroup).Add(this);

                _group.Settings.OnMute          += OnMute;
                _group.Settings.OnPause         += OnPause;
                _group.Settings.OnVolumeChanged += OnVolumeChanged;
            }
        }
예제 #3
0
 public Builder SetGroup(IAudioGroup group)
 {
     _stream.SetGroup(group);
     return(this);
 }