Example #1
0
        protected void AddSource(AudioSettingsBase settings, AudioDynamicData data)
        {
            IAudioItem item = base.AddSource(settings, null);

            if (item == null)
            {
                return;
            }

            if (data.OnInitialize != null)
            {
                data.OnInitialize(item);
                data.OnInitialize = null;
            }

            dynamicData.Add(data);
        }
        public static void ShowPreviewButton(Rect rect, AudioSettingsBase settings)
        {
            if (audioManager == 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;

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

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

                if (previewSettings != settings || (previewItem != null && previewItem.State == AudioStates.Stopping))
                    PlayPreview(settings);
                else if (previewItem != null)
                    previewItem.Stop();
                else
                    StopPreview();
            }

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

            GUI.Label(rect, playing ? "►" : "■", labelStyle);
        }
Example #3
0
 public void StopItemsImmediate(AudioSettingsBase settings)
 {
     Assert.IsNotNull(settings);
     itemManager.StopItemsWithIdentifierImmediate(settings.Identifier);
 }
Example #4
0
 /// <summary>
 /// Creates an AudioItem dynamicaly spatialized using the <paramref name="getPosition"/> callback to set its position that corresponds to the type of the <paramref name="settings"/>.
 /// </summary>
 /// <param name="settings">Settings that will define the behaviour of the AudioItem. </param>
 /// <param name="getPosition">Callback that will be used to update the AudioSource's position.</param>
 /// <returns></returns>
 public IAudioItem CreateItem(AudioSettingsBase settings, Func<Vector3> getPosition)
 {
     Assert.IsNotNull(settings);
     Assert.IsNotNull(getPosition);
     return itemManager.CreateItem(settings, getPosition);
 }
Example #5
0
 /// <summary>
 /// Creates an AudioItem dynamicaly spatialized around the provided Transform that corresponds to the type of the <paramref name="settings"/>.
 /// If the Transform ever becomes <code>null</code>, the AudioItem will simply stop moving.
 /// </summary>
 /// <param name="settings">Settings that will define the behaviour of the AudioItem. </param>
 /// <param name="follow">Transform the the AudioSource will follow.</param>
 /// <returns></returns>
 public IAudioItem CreateItem(AudioSettingsBase settings, Transform follow)
 {
     Assert.IsNotNull(settings);
     Assert.IsNotNull(follow);
     return itemManager.CreateItem(settings, follow);
 }
Example #6
0
 /// <summary>
 /// Creates an AudioItem spatialized at the provided <paramref name="position"/> that corresponds to the type of the <paramref name="settings"/>.
 /// </summary>
 /// <param name="settings">Settings that will define the behaviour of the AudioItem. </param>
 /// <param name="position">Position at which to place the AudioSource.</param>
 /// <returns></returns>
 public IAudioItem CreateItem(AudioSettingsBase settings, Vector3 position)
 {
     Assert.IsNotNull(settings);
     return itemManager.CreateItem(settings, position);
 }
Example #7
0
 /// <summary>
 /// Creates a non spatialized AudioItem that corresponds to the type of the <paramref name="settings"/>.
 /// </summary>
 /// <param name="settings">Settings that will define the behaviour of the AudioItem.</param>
 /// <returns></returns>
 public IAudioItem CreateItem(AudioSettingsBase settings)
 {
     Assert.IsNotNull(settings);
     return itemManager.CreateItem(settings);
 }
        static void StopPreview()
        {
            if (audioManager == null)
                return;

            if (previewItem != null)
            {
                previewItem.StopImmediate();
                previewItem = null;
            }

            if (previewSettings != null)
            {
                EditorUtility.SetDirty(previewSettings);
                EditorApplication.RepaintProjectWindow();
                previewSettings = null;
            }

            if (!Application.isPlaying)
                PrefabPoolManager.ClearPool(audioManager.Reference);

            stopPreview = false;
        }
 static void PlayPreview(AudioSettingsBase settings)
 {
     StopPreview();
     EditorUtility.SetDirty(settings);
     previewSettings = settings;
     previewItem = audioManager.CreateItem(previewSettings);
     previewItem.OnStop += item => { stopPreview = true; previewItem = null; };
     previewItem.Play();
 }
Example #10
0
 /// <summary>
 /// Creates an AudioItem dynamicaly spatialized around the provided Transform that corresponds to the type of the <paramref name="settings"/>.
 /// If the Transform ever becomes <code>null</code>, the AudioItem will simply stop moving.
 /// </summary>
 /// <param name="settings">Settings that will define the behaviour of the AudioItem. </param>
 /// <param name="follow">Transform the the AudioSource will follow.</param>
 /// <returns></returns>
 public IAudioItem CreateItem(AudioSettingsBase settings, Transform follow)
 {
     Assert.IsNotNull(settings);
     Assert.IsNotNull(follow);
     return(itemManager.CreateItem(settings, follow));
 }
Example #11
0
 /// <summary>
 /// Creates an AudioItem spatialized at the provided <paramref name="position"/> that corresponds to the type of the <paramref name="settings"/>.
 /// </summary>
 /// <param name="settings">Settings that will define the behaviour of the AudioItem. </param>
 /// <param name="position">Position at which to place the AudioSource.</param>
 /// <returns></returns>
 public IAudioItem CreateItem(AudioSettingsBase settings, Vector3 position)
 {
     Assert.IsNotNull(settings);
     return(itemManager.CreateItem(settings, position));
 }
Example #12
0
 /// <summary>
 /// Creates a non spatialized AudioItem that corresponds to the type of the <paramref name="settings"/>.
 /// </summary>
 /// <param name="settings">Settings that will define the behaviour of the AudioItem.</param>
 /// <returns></returns>
 public IAudioItem CreateItem(AudioSettingsBase settings)
 {
     Assert.IsNotNull(settings);
     return(itemManager.CreateItem(settings));
 }
Example #13
0
 public void StopItemsImmediate(AudioSettingsBase settings)
 {
     Assert.IsNotNull(settings);
     itemManager.StopItemsWithIdentifierImmediate(settings.Identifier);
 }
Example #14
0
 /// <summary>
 /// Creates an AudioItem dynamicaly spatialized using the <paramref name="getPosition"/> callback to set its position that corresponds to the type of the <paramref name="settings"/>.
 /// </summary>
 /// <param name="settings">Settings that will define the behaviour of the AudioItem. </param>
 /// <param name="getPosition">Callback that will be used to update the AudioSource's position.</param>
 /// <returns></returns>
 public IAudioItem CreateItem(AudioSettingsBase settings, Func <Vector3> getPosition)
 {
     Assert.IsNotNull(settings);
     Assert.IsNotNull(getPosition);
     return(itemManager.CreateItem(settings, getPosition));
 }
        protected void AddSource(AudioSettingsBase settings, AudioDynamicData data)
        {
            IAudioItem item = base.AddSource(settings, null);

            if (item == null)
                return;

            if (data.OnInitialize != null)
            {
                data.OnInitialize(item);
                data.OnInitialize = null;
            }

            dynamicData.Add(data);
        }