BGM轮播模块

This commit is contained in:
daixiawu 2026-03-11 20:45:29 +08:00
parent 25289fc969
commit 6d8879a98d
9 changed files with 593 additions and 4 deletions

View File

@ -113,6 +113,234 @@ MonoBehaviour:
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1.5
--- !u!1 &563940503794531547
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2198070166334616661}
- component: {fileID: 337039894085223893}
- component: {fileID: 7812593039037503165}
m_Layer: 5
m_Name: Checkmark
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2198070166334616661
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 563940503794531547}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 6840789288920572074}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 20, y: 20}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &337039894085223893
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 563940503794531547}
m_CullTransparentMesh: 1
--- !u!114 &7812593039037503165
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 563940503794531547}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 10901, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &970534023373209754
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7705712282840003427}
- component: {fileID: 7855347025434628650}
- component: {fileID: 7344069557332280943}
- component: {fileID: 6996816402160800761}
m_Layer: 5
m_Name: Label
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &7705712282840003427
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 970534023373209754}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 3353149732663546376}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 19.908493, y: -0.0000076293945}
m_SizeDelta: {x: -39.817, y: -0.000015259}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &7855347025434628650
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 970534023373209754}
m_CullTransparentMesh: 1
--- !u!114 &7344069557332280943
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 970534023373209754}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: "\u59CB\u7EC8\u64AD\u653EBGM\n"
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8e119f168f1a6b745be02ef19f51610f, type: 2}
m_sharedMaterial: {fileID: -8081454072124122709, guid: 8e119f168f1a6b745be02ef19f51610f, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4285217601
m_fontColor: {r: 0.25490198, g: 0.23137257, b: 0.41960788, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 24
m_fontSizeBase: 24
m_fontWeight: 400
m_enableAutoSizing: 1
m_fontSizeMin: 1
m_fontSizeMax: 24
m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!114 &6996816402160800761
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 970534023373209754}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6b27f832d22e4a8d916272b644937774, type: 3}
m_Name:
m_EditorClassIdentifier:
Ban: 0
NoExport: 0
FontBan: 0
ID: 17703
FontID: 0
TextCfg: []
--- !u!1 &1057261517439167008
GameObject:
m_ObjectHideFlags: 0
@ -1950,6 +2178,82 @@ MonoBehaviour:
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &2569914005338302020
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6840789288920572074}
- component: {fileID: 5722359200470022000}
- component: {fileID: 8724487321124132934}
m_Layer: 5
m_Name: Background
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &6840789288920572074
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2569914005338302020}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2198070166334616661}
m_Father: {fileID: 3353149732663546376}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 16.7251, y: -21.3}
m_SizeDelta: {x: 33.4501, y: 33.4501}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &5722359200470022000
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2569914005338302020}
m_CullTransparentMesh: 1
--- !u!114 &8724487321124132934
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2569914005338302020}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &2669982059935206767
GameObject:
m_ObjectHideFlags: 0
@ -3254,6 +3558,92 @@ MonoBehaviour:
WordSpacing: 0
LineSpacing: 0
ParagraphSpacing: 0
--- !u!1 &4147537225182568512
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3353149732663546376}
- component: {fileID: 5173756232815940152}
m_Layer: 5
m_Name: AlwaysMusicToggle
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &3353149732663546376
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4147537225182568512}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 6840789288920572074}
- {fileID: 7705712282840003427}
m_Father: {fileID: 5696276800239901883}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 171, y: -0.000014625}
m_SizeDelta: {x: 316.52, y: 43.455}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &5173756232815940152
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4147537225182568512}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9085046f02f69544eb97fd06b6048fe2, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 8724487321124132934}
toggleTransition: 1
graphic: {fileID: 7812593039037503165}
m_Group: {fileID: 0}
onValueChanged:
m_PersistentCalls:
m_Calls: []
m_IsOn: 1
--- !u!1 &4440741658872348074
GameObject:
m_ObjectHideFlags: 0
@ -3655,7 +4045,7 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: "\u5F39\u7A97\u8BBE\u7F6E"
m_text: "\u5176\u4ED6\u8BBE\u7F6E"
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: ce4904f8ddac15944907907115531ad5, type: 2}
m_sharedMaterial: {fileID: 1214840240034325189, guid: ce4904f8ddac15944907907115531ad5, type: 2}
@ -5957,6 +6347,7 @@ MonoBehaviour:
BlockButton: {fileID: 5282322453820411557}
LanguageOptionGroup: {fileID: 3444656944565885498}
KeyMomentToggle: {fileID: 4395786735994074065}
BgmContinuousToggle: {fileID: 5173756232815940152}
--- !u!1 &7930589923607781044
GameObject:
m_ObjectHideFlags: 0
@ -6544,6 +6935,7 @@ RectTransform:
m_ConstrainProportionsScale: 1
m_Children:
- {fileID: 7436857949775915417}
- {fileID: 3353149732663546376}
m_Father: {fileID: 8744354601687060637}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}

View File

@ -27,7 +27,15 @@ namespace Logic.Audio
private GameObject AudioRoot;
private Dictionary<string, float> _musicRecord;
// BGM 轮播相关
private bool _isPlayingRotation = false;
private float _rotationInterval = 30f;
private float _rotationTimer = 0f;
private List<string> _activePlayerMusics = new List<string>();
private int _currentMusicIndex = 0;
private string _lastPlayedMusicName = null;
public void Init()
{
_allPlayer = new List<AudioPlayer>();
@ -102,6 +110,9 @@ namespace Logic.Audio
_clips[player.MusicName].Add(player.Clip);
player.Clip = null;
}
// 更新 BGM 轮播
UpdateBgmRotation();
}
public void PlayMusic(string musicName, float fadeIn, float fadeOut, bool isLoop, bool isContinue=true)
@ -150,6 +161,153 @@ namespace Logic.Audio
}
}
#region BGM
/// <summary>
/// 开始 BGM 轮播
/// </summary>
public void StartBgmRotation()
{
if (!ConfigManager.Instance.Config.BgmContinuousPlay) return;
_isPlayingRotation = true;
_rotationTimer = 0f;
UpdateActivePlayerMusics();
PlayNextRotationMusic();
}
/// <summary>
/// 停止 BGM 轮播
/// </summary>
public void StopBgmRotation()
{
_isPlayingRotation = false;
}
/// <summary>
/// 如果配置开启,恢复 BGM 轮播UI 关闭时调用)
/// </summary>
public void ResumeBgmRotationIfEnabled()
{
if (!ConfigManager.Instance.Config.BgmContinuousPlay) return;
_isPlayingRotation = true;
// 如果当前没有播放音乐或播放的不是轮播列表中的音乐,立即播放
if (_musicPlayer == null || _musicPlayer.State == PlayerState.Finished ||
!_activePlayerMusics.Contains(_musicPlayer.MusicName))
{
UpdateActivePlayerMusics();
if (_activePlayerMusics.Count > 0)
{
PlayNextRotationMusic();
}
}
}
/// <summary>
/// 更新当前场上所有已遇见玩家的音乐列表
/// </summary>
public void UpdateActivePlayerMusics()
{
if (Main.MapData == null || Main.MapData.PlayerMap == null) return;
_activePlayerMusics.Clear();
var uniqueMusicNames = new HashSet<string>();
var selfPlayer = Main.MapData.PlayerMap.SelfPlayerData;
// 遍历所有已遇见的玩家包括自己自己在MeetPlayers列表中
foreach (var playerId in selfPlayer.MeetPlayers)
{
if (!Main.MapData.PlayerMap.GetPlayerDataByPlayerID(playerId, out var player)) continue;
if (Table.Instance.PlayerDataAssets.GetPlayerInfo(player, out var playerInfo))
{
if (!string.IsNullOrEmpty(playerInfo.MusicName) && _clips.ContainsKey(playerInfo.MusicName))
{
uniqueMusicNames.Add(playerInfo.MusicName);
}
}
}
_activePlayerMusics.AddRange(uniqueMusicNames);
// 随机打乱顺序
ShuffleList(_activePlayerMusics);
}
/// <summary>
/// BGM 轮播更新(在 Update 中调用)
/// </summary>
private void UpdateBgmRotation()
{
if (!_isPlayingRotation) return;
if (!ConfigManager.Instance.Config.BgmContinuousPlay)
{
StopBgmRotation();
return;
}
// 如果当前没有播放或播放完毕,计时器不减少
if (_musicPlayer == null || _musicPlayer.State == PlayerState.Finished)
{
// 如果没有音乐在播放,尝试播放下一首
if (_activePlayerMusics.Count > 0)
{
PlayNextRotationMusic();
}
return;
}
// 只在音乐正在播放时计时
if (_musicPlayer.State == PlayerState.Playing)
{
_rotationTimer -= Time.deltaTime;
if (_rotationTimer <= 0)
{
PlayNextRotationMusic();
}
}
}
/// <summary>
/// 播放轮播列表中的下一首音乐
/// </summary>
private void PlayNextRotationMusic()
{
if (_activePlayerMusics.Count == 0)
{
UpdateActivePlayerMusics();
if (_activePlayerMusics.Count == 0) return;
}
// 获取下一首音乐
_currentMusicIndex = (_currentMusicIndex + 1) % _activePlayerMusics.Count;
var musicName = _activePlayerMusics[_currentMusicIndex];
// 避免重复播放同一首(如果列表有多首)
if (_activePlayerMusics.Count > 1 && musicName == _lastPlayedMusicName)
{
_currentMusicIndex = (_currentMusicIndex + 1) % _activePlayerMusics.Count;
musicName = _activePlayerMusics[_currentMusicIndex];
}
_lastPlayedMusicName = musicName;
PlayMusic(musicName, 2f, 2f, false); // 不循环,使用轮播
_rotationTimer = _rotationInterval;
}
/// <summary>
/// 打乱列表顺序
/// </summary>
private void ShuffleList(List<string> list)
{
for (int i = list.Count - 1; i > 0; i--)
{
int j = UnityEngine.Random.Range(0, i + 1);
var temp = list[i];
list[i] = list[j];
list[j] = temp;
}
}
#endregion
public void PlayAudio(string musicName, float fadeIn = 0f, float fadeOut = 0f, bool isLoop = false)
{
if (!_clips.ContainsKey(musicName)) return;

View File

@ -194,6 +194,8 @@ namespace TH1_Logic.Config
private bool _showReminder;
[SerializeField]
private bool _keyMomentEnabled;
[SerializeField]
private bool _bgmContinuousPlay;
private bool _isChanged;
public bool IsChanged => _isChanged;
@ -234,6 +236,16 @@ namespace TH1_Logic.Config
_audioVolume = value;
}
}
public bool BgmContinuousPlay
{
get => _bgmContinuousPlay;
set
{
if (_bgmContinuousPlay == value) return;
_isChanged = true;
_bgmContinuousPlay = value;
}
}
public bool ShowReminder
{
get => _showReminder;
@ -263,6 +275,7 @@ namespace TH1_Logic.Config
_audioVolume = 0.5f;
_showReminder = true;
_keyMomentEnabled = true;
_bgmContinuousPlay = false;
}
}
}

View File

@ -47,6 +47,7 @@ namespace TH1_UI.View.Announce
Main.MapData.PlayerMap.SelfPlayerData.AddCoin_ViewOnly(_param2,pos);
}
OnBtnCloseClick.Invoke();
AudioManager.Instance.ResumeBgmRotationIfEnabled();
});
_grayScaleMat = Resources.Load<Material>("Materials/GrayScale");

View File

@ -458,6 +458,7 @@ namespace TH1_UI.View.Info
public void CloseView()
{
AudioManager.Instance.StopMusic();
Logic.Audio.AudioManager.Instance.ResumeBgmRotationIfEnabled();
}
}

View File

@ -688,7 +688,8 @@ namespace TH1_UI.View.Info
public void CloseView()
{
AudioManager.Instance.StopMusic();
// 不停止音乐,只恢复轮播(如果正在播放的不是轮播音乐,会继续播放)
Logic.Audio.AudioManager.Instance.ResumeBgmRotationIfEnabled();
}
}

View File

@ -234,6 +234,7 @@ namespace TH1_UI.View.Info
public void CloseView()
{
AudioManager.Instance.StopMusic();
AudioManager.Instance.ResumeBgmRotationIfEnabled();
}
}

View File

@ -193,6 +193,7 @@ namespace TH1_UI.View.Info
public void CloseView()
{
AudioManager.Instance.StopMusic();
Logic.Audio.AudioManager.Instance.ResumeBgmRotationIfEnabled();
}
}

View File

@ -18,6 +18,7 @@ namespace TH1_UI.View.Top
public UIOutsideSelectOptionGroupMono LanguageOptionGroup;
public Toggle KeyMomentToggle;
public Toggle BgmContinuousToggle;
protected override void OnInit()
{
@ -33,13 +34,24 @@ namespace TH1_UI.View.Top
KeyMomentToggle.onValueChanged.RemoveAllListeners();
KeyMomentToggle.onValueChanged.AddListener(OnKeyMomentToggleChanged);
}
if (BgmContinuousToggle != null)
{
BgmContinuousToggle.onValueChanged.RemoveAllListeners();
BgmContinuousToggle.onValueChanged.AddListener(OnBgmContinuousToggleChanged);
}
}
private void OnKeyMomentToggleChanged(bool isOn)
{
ConfigManager.Instance.Config.KeyMomentEnabled = isOn;
}
private void OnBgmContinuousToggleChanged(bool isOn)
{
ConfigManager.Instance.Config.BgmContinuousPlay = isOn;
}
public void RefreshLanguageOption()
{
var lan = MultilingualManager.Instance.GetCurLanguage();
@ -85,6 +97,7 @@ namespace TH1_UI.View.Top
{
RefreshLanguageOption();
RefreshKeyMomentToggle();
RefreshBgmContinuousToggle();
}
public void RefreshKeyMomentToggle()
@ -94,6 +107,14 @@ namespace TH1_UI.View.Top
KeyMomentToggle.isOn = ConfigManager.Instance.Config.KeyMomentEnabled;
}
}
public void RefreshBgmContinuousToggle()
{
if (BgmContinuousToggle != null)
{
BgmContinuousToggle.isOn = ConfigManager.Instance.Config.BgmContinuousPlay;
}
}
public void CloseView()
{