修复声音设置

This commit is contained in:
2026-06-28 00:45:03 +08:00
parent d7bc58167b
commit 20d9544dc7
7 changed files with 87 additions and 3 deletions
+2 -2
View File
@@ -35,10 +35,10 @@ public class AudioManager : MonoSingleton<AudioManager>
}
float value = PlayerPrefs.GetFloat("slider_AudioBG");
audioMixer.SetFloat("BGVolume", value * 100 - 80);
audioMixer.SetFloat("BGVolume", 20.0f * Mathf.Log10(Mathf.Max(value, 0.0001f)));
value = PlayerPrefs.GetFloat("slider_FX");
audioMixer.SetFloat("FXVolume", value*100-80);
audioMixer.SetFloat("FXVolume", 20.0f * Mathf.Log10(Mathf.Max(value, 0.0001f)));
dic_audioList[AudioType.BG].outputAudioMixerGroup = audioMixer.FindMatchingGroups("Master/BG")[0];
dic_audioList[AudioType.FX].outputAudioMixerGroup = audioMixer.FindMatchingGroups("Master/FX")[0];
}
@@ -75,5 +75,10 @@ namespace Assets.MyGame.Scripts.Net.API
/// 击杀配置
/// </summary>
public object killConfig;
/// <summary>
/// 象棋配置
/// </summary>
public ChessConfig chessConfig;
}
}
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
namespace Assets.MyGame.Scripts.Net.API.GameConfig_SubClass
{
/// <summary>
/// 象棋配置
/// </summary>
[Serializable]
public class ChessConfig
{
/// <summary>创建房间限制 1 vip 2 代理商 3 普通用户</summary>
public List<int> createRoomLimit;
/// <summary>最小投注金币</summary>
public long minBetGold;
/// <summary>投注金币限制列表</summary>
public List<long> betGoldLimits;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 04679bca9a39c8c4084ea5fa0864533b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -1771,6 +1771,13 @@ MonoBehaviour:
tmp_CurrGlod: {fileID: 6468753285455309694}
tmpInput_Coin: {fileID: 3126247594640834412}
btn_Enter: {fileID: 2826394579243728725}
jinerList:
- {fileID: 4399664319064742888}
- {fileID: 6199326318943480037}
- {fileID: 4044324667058174783}
- {fileID: 6902807486243113198}
- {fileID: 2194459829576141627}
- {fileID: 4356994284705232430}
--- !u!1 &4002775877117272818
GameObject:
m_ObjectHideFlags: 0
@@ -11,7 +11,7 @@ public class UIChineseChessSetCoin : SubUIBase
public TextMeshProUGUI tmp_CurrGlod;
public TMP_InputField tmpInput_Coin;
public Button btn_Enter;
public List<Button> jinerList; // 金额按钮列表 子对象第0个是textmeshprougui 设置金额
public List<Button> jinerList; // 金额按钮列表 子对象第0个是textmeshprougui 设置金额 这里有6个按钮
private ChineseChessGameClassList.ChessGameRoom roomData;
@@ -29,6 +29,30 @@ public class UIChineseChessSetCoin : SubUIBase
tmp_CurrGlod.text = ChineseChessMainPanel.FormatGold(GameManager.Instance.user.assets.gold);
btn_Enter.onClick.RemoveAllListeners();
btn_Enter.onClick.AddListener(OnEnter);
// 加载快捷金额按钮
LoadBetGoldLimits();
}
}
private void LoadBetGoldLimits()
{
var limits = GameManager.Instance.gameConfig?.chessConfig?.betGoldLimits;
if (limits == null) return;
for (int i = 0; i < jinerList.Count && i < limits.Count; i++)
{
long amount = limits[i];
// child(0) 设置带单位的金额文本
jinerList[i].transform.GetChild(0).GetComponent<TextMeshProUGUI>().text
= ChineseChessMainPanel.FormatGold(amount);
long captured = amount;
jinerList[i].onClick.RemoveAllListeners();
jinerList[i].onClick.AddListener(() =>
{
tmpInput_Coin.text = captured.ToString();
});
}
}
@@ -2,7 +2,9 @@ using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.UI;
using static UnityEngine.Rendering.DebugUI;
public class UIHome_BY_SettingPanel : SubUIBase
{
@@ -34,11 +36,25 @@ public class UIHome_BY_SettingPanel : SubUIBase
{
PlayerPrefs.SetFloat("slider_AudioBG", a);
PlayerPrefs.Save();
// 1. 确保值不会为0
float linearValue = Mathf.Max(a, 0.0001f);
// 2. 转换为分贝
float dBValue = 20.0f * Mathf.Log10(linearValue);
AudioManager.Instance.audioMixer.SetFloat("BGVolume", dBValue);
});
slider_AudioEffect.onValueChanged.AddListener((a) =>
{
PlayerPrefs.SetFloat("slider_FX", a);
PlayerPrefs.Save();
// 1. 确保值不会为0
float linearValue = Mathf.Max(a, 0.0001f);
// 2. 转换为分贝
float dBValue = 20.0f * Mathf.Log10(linearValue);
AudioManager.Instance.audioMixer.SetFloat("FXVolume", dBValue);
});
// 画质