示例#1
0
    /// <summary>
    /// 播放音乐片段
    /// </summary>
    /// <param name="onClickEnum"></param>
    public static void playSoundClip(AudioButtonOnClickEnum onClickEnum)
    {
        if (CommonConfigure.IsOpenSound == EnabledEnum.OFF)
        {
            return;
        }
        AudioSourceControl control = Camera.main.GetComponent <AudioSourceControl>();

        if (control != null)
        {
            control.playSoundClip(onClickEnum);
        }
    }
示例#2
0
    /// <summary>
    /// 播放按钮点击音效
    /// </summary>
    /// <param name="onClickEnum"></param>
    public void playSoundClip(AudioButtonOnClickEnum onClickEnum)
    {
        string soundPath = "Sound/Clip/";

        switch (onClickEnum)
        {
        case AudioButtonOnClickEnum.btn_sound_1:
            soundPath += "btn_sound_1";
            break;

        case AudioButtonOnClickEnum.btn_sound_2:
            soundPath += "btn_sound_2";
            break;

        case AudioButtonOnClickEnum.btn_sound_3:
            soundPath += "btn_sound_3";
            break;

        case AudioButtonOnClickEnum.merge_sound_1:
            soundPath += "merge_sound_1";
            break;

        case AudioButtonOnClickEnum.merge_sound_2:
            soundPath += "merge_sound_2";
            break;

        case AudioButtonOnClickEnum.merge_sound_3:
            soundPath += "merge_sound_3";
            break;

        case AudioButtonOnClickEnum.merge_sound_4:
            soundPath += "merge_sound_4";
            break;
        }

        AudioClip tempClip = ResourcesManager.LoadData <AudioClip>(soundPath);

        if (tempClip != null)
        {
            AudioSource.PlayClipAtPoint(tempClip, transform.position, CommonConfigure.SoundVolume);
        }
    }