Beispiel #1
0
    private void InitAudio()
    {
        //初始化的时候,去获取音源组件
        audioSource = GameTool.GetTheChildComponent <AudioSource>(this.gameObject, "AudioManager");
        if (!GameTool.HasKey("AudioValue"))
        {
            GameTool.SetFloat("AudioValue", 0.5f);
            audioValue = 0.5f;
        }
        else
        {
            audioValue         = GameTool.GetFloat("AudioValue");
            audioSource.volume = audioValue;
        }

        if (!GameTool.HasKey("Mute"))
        {
            GameTool.SetString("Mute", "false");
            isMute = false;
        }
        else
        {
            isMute           = bool.Parse(GameTool.GetString("Mute"));
            audioSource.mute = isMute;
        }
    }