示例#1
0
        public static AudioClip PreviewGroup(SfxGroup group)
        {
            AudioClip clip = group.GetClip();

            PlayClip(clip, group);
            return(clip);
        }
示例#2
0
        public static void PlayClip(AudioClip clip, SfxGroup group)
        {
            var go = EditorUtility.CreateGameObjectWithHideFlags("PLAY_AUDIO_TEMP", HideFlags.HideAndDontSave);

            AudioSource source = go.AddComponent <AudioSource> ();

            source.clip   = clip;
            source.volume = UnityEngine.Random.Range(group.VolumeRange.x, group.VolumeRange.y);
            source.pitch  = UnityEngine.Random.Range(group.PitchRange.x, group.PitchRange.y);
            source.Play();
        }
示例#3
0
        public override void OnInspectorGUI()
        {
            SfxGroup group = (SfxGroup)target;

            DrawDefaultInspector();

            if (GUILayout.Button("Play Clips"))
            {
                lastPlayed = PreviewGroup(group).name;
            }
            EditorGUILayout.LabelField(lastPlayed);
        }
示例#4
0
        public static bool OpenAsset(int instanceID, int line)
        {
            var asset = EditorUtility.InstanceIDToObject(instanceID);

            if (typeof(SfxGroup).IsAssignableFrom(asset.GetType()))
            {
                SfxGroup group = (SfxGroup)asset;
                PreviewGroup(group);
                return(true);
            }
            return(false);
        }
示例#5
0
    public void PlayClip(SfxGroup group)
    {
        var source = Pool.Grab();

        source.clip   = group.GetClip();
        source.volume = UnityEngine.Random.Range(group.VolumeRange.x, group.VolumeRange.y);
        source.pitch  = UnityEngine.Random.Range(group.PitchRange.x, group.PitchRange.y);
        source.loop   = false;

        var animator = new AudioSourceAnimator(source, TabFade, MasterVolume, SfxVolume);

        Animators.Add(animator);

        source.Play();
        StartCoroutine(ReturnToPool(animator));
    }
示例#6
0
 public static void Play(SfxGroup group)
 {
     instance.PlayClip(group);
 }