예제 #1
0
        public IEnumerator TestPlay()
        {
            Assert.IsNull(source.clip);
            item.Play(source);
            yield return(null);

            Assert.IsNotNull(source.clip);
        }
예제 #2
0
        public AudioItem Play(string soundName, GameObject source, float delay, SyncMode syncMode, params AudioOption[] audioOptions)
        {
            AudioItem audioItem = GetAudioItem(soundName, source, audioOptions);

            if (syncMode != SyncMode.None)
            {
                audioItem.Play(delay, syncMode);
            }
            else
            {
                audioItem.Play(delay);
            }
            return(audioItem);
        }
예제 #3
0
        public AudioItem Play(string soundName, GameObject source, params AudioOption[] audioOptions)
        {
            AudioItem audioItem = GetAudioItem(soundName, source, audioOptions);

            audioItem.Play();
            return(audioItem);
        }
예제 #4
0
        public IEnumerator TestPlayOneSound()
        {
            item = new AudioItem(true, true, 1f, 0.9f, 1.1f, true, 1f, step1);

            Assert.IsNull(source.clip);
            item.Play(source);
            yield return(null);

            Assert.AreEqual(source.clip, step1);
        }
        public static void ShowPreviewButton(Rect rect, AudioSettingsBase settings)
        {
            if (AudioManager.Find() == null)
                return;

            // Check if scrollbar is visible
            if (Screen.width - rect.x - rect.width > 5f)
                rect.x = Screen.width - 40f;
            else
                rect.x = Screen.width - 24f;

            rect.width = 21f;
            rect.height = 16f;

            GUIStyle buttonStyle = new GUIStyle("MiniToolbarButtonLeft");
            buttonStyle.fixedHeight += 1;

            if (GUI.Button(rect, "", buttonStyle))
            {
                Selection.activeObject = settings;

                if (_previewSettings != settings || (_previewItem != null && _previewItem.State == AudioItem.AudioStates.Stopping))
                {
                    StopPreview();

                    EditorUtility.SetDirty(settings);
                    _previewSettings = settings;
                    _previewItem = AudioManager.Instance.CreateItem(_previewSettings);
                    _previewItem.OnStop += item => { StopPreview(); EditorUtility.SetDirty(settings); EditorApplication.RepaintProjectWindow(); };
                    _previewItem.Play();
                }
                else if (_previewItem != null)
                    _previewItem.Stop();
                else
                    StopPreview();
            }

            bool playing = _previewItem == null || _previewItem.State == AudioItem.AudioStates.Stopping || _previewSettings != settings;
            GUIStyle labelStyle = new GUIStyle("boldLabel");
            labelStyle.fixedHeight += 1;
            labelStyle.fontSize = playing ? 14 : 20;
            labelStyle.contentOffset = playing ? new Vector2(2f, -1f) : new Vector2(2f, -8f);
            labelStyle.clipping = TextClipping.Overflow;

            GUI.Label(rect, playing ? "►" : "■", labelStyle);
        }
예제 #6
0
    public override AudioObject Play(string audioItemId, Transform parent = null, Vector3 point = default(Vector3))
    {
        AudioCategory ac;
        AudioItem     ai = GetAudioItem(audioItemId, out ac);

        if (ai != null)
        {
            ac.lastPlayedId = audioItemId;
            if (ac.IsActive)
            {
                //create audio object from this audio Item and play it
                AudioObject AM_pAOPrefab = (ac.audioObjPrefab == null ? audioObjDefaultPrefab : ac.audioObjPrefab);
                AudioObject result       = ai.Play(parent, point, ac.GetVolume() * globalVolume, ref AM_pAOPrefab);
                if (result != null)
                {
                    if (ac.onlyOneItemAllowed)
                    {
                        ac.StopAllAudiosExceptThis(ai.itemId, result.Id);
                    }
                }
                return(result);
            }
            else
            {
                if (_isLogged)
                {
                    Debug.LogFormat(this, "AudioCategory[{0}] for Item[{1}] is not Active!", ac.categoryId, audioItemId);
                }
            }
        }
        else
        {
            if (_isLogged)
            {
                Debug.LogFormat(this, "AudioItem [{0}] not founded!", audioItemId);
            }
        }
        return(null);
    }
예제 #7
0
        public void ApplyAction()
        {
            if (isApplied)
            {
                return;
            }

            switch (type)
            {
            case ActionTypes.Play:
                audioItem.Play();
                break;

            case ActionTypes.Pause:
                audioItem.Pause();
                break;

            case ActionTypes.Stop:
                audioItem.Stop();
                break;
            }
            isApplied = true;
        }