Exemple #1
0
 static void StopButton(Rect r)
 {
     if (GUI.Button(r, "■", Styles.btStop))
     {
         DeEditorSoundUtils.StopAll();
     }
 }
Exemple #2
0
 static void PlayButton(Rect r, DeAudioClipData value)
 {
     if (GUI.Button(r, "►", Styles.btPlay))
     {
         DeEditorSoundUtils.StopAll();
         if (value.clip != null)
         {
             DeEditorSoundUtils.Play(value.clip);
         }
     }
 }
Exemple #3
0
        void Stop(SerializedProperty property)
        {
            MonoBehaviour m = GetValidMonoBehaviour(property);

            if (m == null)
            {
                DeEditorSoundUtils.StopAll();
                return;
            }
            AudioSource s = m.GetComponent <AudioSource>();

            if (s == null)
            {
                return;
            }

            s.Stop();
        }
Exemple #4
0
        void Play(SerializedProperty property)
        {
            AudioClip clip = property.FindPropertyRelative("clip").objectReferenceValue as AudioClip;

            if (clip == null)
            {
                return;
            }
            MonoBehaviour m = GetValidMonoBehaviour(property);

            if (m == null)
            {
                // Can't use AudioSource: play clip regardless of volume
                DeEditorSoundUtils.StopAll();
                DeEditorSoundUtils.Play(clip);
                return;
            }
            AudioSource s = m.GetComponent <AudioSource>();

            if (s == null)
            {
                if (EditorUtility.DisplayDialog("Play DeAudioClipData", "Add AudioSource to preview the clip with the correct volume?", "Ok", "Cancel"))
                {
                    s = m.gameObject.AddComponent <AudioSource>();
                }
            }
            if (s == null)
            {
                return;
            }
            s.playOnAwake = false;
            s.volume      = property.FindPropertyRelative("volume").floatValue;
            s.pitch       = property.FindPropertyRelative("pitch").floatValue;
            s.loop        = property.FindPropertyRelative("loop").boolValue;
            s.clip        = clip;
            s.Play();
        }