示例#1
0
        private void PlayAudioAutomaticEnableStart()
        {
            PYPlayer audio = GetDefaultAudio("Default");

            if (audio is PYPlayerClip)
            {
                PYPlayerClip audioClip = (PYPlayerClip)audio;
                if (PYBundleManager.Instance != null)
                {
                    if (audioClip.UpdateData.UpdateFromBundle && PYBundleManager.Instance.IsReady)
                    {
                        Invoke("Play", DelayStartEnable);
                    }
                    else
                    {
                        PYBundleManager.Instance.onLoadCompleted.AddListener(PlayDefaultAudioWhenBundleLoads);
                    }
                }
                else if (audioClip.Clip != null)
                {
                    Invoke("Play", DelayStartEnable);
                }
            }
            else
            {
                Invoke("Play", DelayStartEnable);
            }
        }
示例#2
0
        public PYPlayer StartAudio(string name)
        {
            // TODO: Dont makes much sense this, but works
            PYPlayer audio = GetDefaultAudio(name);

            audio.PYSource = audio.StartAudio();
            return(audio);
        }
示例#3
0
        public PYPlayer GetDefaultAudio(string name)
        {
            PYPlayer audio = GetPYAudio(name);

            // If any default is found we get the first audio
            if (audio == null)
            {
                audio = Audios[0];
            }
            return(audio);
        }
示例#4
0
        public void Play(string name, Action <PYAudioSource.PYAudioSourceEventData> callback)
        {
            PYPlayer      player = StartAudio(name);
            PYAudioSource source = player.PYSource;

            if (source == null)
            {
                return;
            }

            source.Volume(player.Volume)
            .Pitch(player.Pitch)
            .Delay(player.Delay)
            .Loop(player.Loop).Play(callback);
        }
示例#5
0
        public void Play(string name)
        {
            PYPlayer      player = StartAudio(name);
            PYAudioSource source = player.PYSource;

            if (source == null)
            {
                return;
            }

            source.Volume(player.Volume)
            .Pitch(player.Pitch)
            .Delay(player.Delay)
            .Loop(player.Loop).Play();
        }
示例#6
0
        void ShowPYPlayer(PYPlayer elem)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(10);
            elem.IsShowingElement = EditorGUILayout.Foldout(elem.IsShowingElement, string.Format(AUDIO_ITEM_NAME, elem.Name, elem.GetType().ToString()));
            if (GUILayout.Button("-", GUILayout.Width(40)))
            {
                Undo.RecordObject(target, "Removed Elem");
                _target.Audios.Remove(elem);

                EditorUtility.SetDirty(target);
                return;
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Space(10);
            GUILayout.BeginVertical();
            if (elem.IsShowingElement)
            {
                if (elem is PYPlayerTag)
                {
                    PYPlayerTag playerTag = (PYPlayerTag)elem;
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("PYAudio Tag");
                    if (GUILayout.Button(playerTag.Tag.ToString()))
                    {
                        PYSelectorWindow.Init(_rectButtonTag, playerTag.Tag.ToString(),
                                              Enum.GetNames(typeof(PYAudioTags)), (selectedItem) =>
                        {
                            playerTag.Tag = (PYAudioTags)Enum.Parse(typeof(PYAudioTags), selectedItem.Value);
                        });
                    }

                    GUILayout.EndHorizontal();
                }
                else if (elem is PYPlayerClip)
                {
                    PYPlayerClip playerClip = (PYPlayerClip)elem;
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Asset Tag");
                    string tag = string.IsNullOrEmpty(playerClip.AssetTag.UnprocessedTag) ?
                                 "None" : playerClip.AssetTag.UnprocessedTag.Split(':')[0];
                    if (GUILayout.Button(tag))
                    {
                        string[] tags = PYBundleManager.GetAssetsTag();
                        tags = tags.Where(t => t.Contains(": Audio")).ToArray();

                        PYSelectorWindow.Init(_rectButtonTag, tag, tags, (selectedItem) =>
                        {
                            playerClip.AssetTag.UnprocessedTag = selectedItem.Value;
                        });
                    }

                    GUILayout.EndHorizontal();
                }

                if (Event.current.type == EventType.Repaint)
                {
                    _rectButtonTag = GUILayoutUtility.GetLastRect();
                }

                elem.DrawInspector();
                GUILayout.Space(5);
            }
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
        }