- 完善设置面板的具体功能,全局性的设置项已经可以发挥作用了

- 调整部分项目结构和AB包设置,打包测试设置面板的功能
This commit is contained in:
SepComet
2026-02-11 14:58:05 +08:00
parent 13583354f9
commit deb2c01d01
64 changed files with 536 additions and 1536 deletions
+15 -78
View File
@@ -1,33 +1,25 @@
//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
using CustomUtility;
using CustomUtility;
using DataTable;
using Definition;
using Entity;
using GameFramework;
using GameFramework.DataTable;
using GameFramework.Sound;
using UnityGameFramework.Runtime;
namespace StarForce
namespace Sound
{
public static class SoundExtension
{
private const float FadeVolumeDuration = 1f;
private static int? s_MusicSerialId = null;
public static int? PlayMusic(this SoundComponent soundComponent, int musicId, object userData = null)
public static int? PlayBGM(this SoundComponent soundComponent, int musicId, object userData = null)
{
soundComponent.StopMusic();
IDataTable<DRMusic> dtMusic = GameEntry.DataTable.GetDataTable<DRMusic>();
DRMusic drMusic = dtMusic.GetDataRow(musicId);
if (drMusic == null)
IDataTable<DRBGM> dtMusic = GameEntry.DataTable.GetDataTable<DRBGM>();
DRBGM drBgm = dtMusic.GetDataRow(musicId);
if (drBgm == null)
{
Log.Warning("Can not load music '{0}' from data table.", musicId.ToString());
return null;
@@ -39,7 +31,8 @@ namespace StarForce
playSoundParams.VolumeInSoundGroup = 1f;
playSoundParams.FadeInSeconds = FadeVolumeDuration;
playSoundParams.SpatialBlend = 0f;
s_MusicSerialId = soundComponent.PlaySound(AssetUtility.GetMusicAsset(drMusic.AssetName), "Music", Constant.AssetPriority.MusicAsset, playSoundParams, null, userData);
s_MusicSerialId = soundComponent.PlaySound(AssetUtility.GetMusicAsset(drBgm.AssetName), "BGM",
Constant.AssetPriority.MusicAsset, playSoundParams, null, userData);
return s_MusicSerialId;
}
@@ -54,28 +47,10 @@ namespace StarForce
s_MusicSerialId = null;
}
public static int? PlaySound(this SoundComponent soundComponent, int soundId, EntityBase bindingEntity = null, object userData = null)
public static int? PlaySE(this SoundComponent soundComponent, int uiSoundId, object userData = null)
{
IDataTable<DRSound> dtSound = GameEntry.DataTable.GetDataTable<DRSound>();
DRSound drSound = dtSound.GetDataRow(soundId);
if (drSound == null)
{
Log.Warning("Can not load sound '{0}' from data table.", soundId.ToString());
return null;
}
PlaySoundParams playSoundParams = PlaySoundParams.Create();
playSoundParams.Priority = drSound.Priority;
playSoundParams.Loop = drSound.Loop;
playSoundParams.VolumeInSoundGroup = drSound.Volume;
playSoundParams.SpatialBlend = drSound.SpatialBlend;
return soundComponent.PlaySound(AssetUtility.GetSoundAsset(drSound.AssetName), "Sound", Constant.AssetPriority.SoundAsset, playSoundParams, bindingEntity != null ? bindingEntity.Entity : null, userData);
}
public static int? PlayUISound(this SoundComponent soundComponent, int uiSoundId, object userData = null)
{
IDataTable<DRUISound> dtUISound = GameEntry.DataTable.GetDataTable<DRUISound>();
DRUISound drUISound = dtUISound.GetDataRow(uiSoundId);
IDataTable<DRSE> dtUISound = GameEntry.DataTable.GetDataTable<DRSE>();
DRSE drUISound = dtUISound.GetDataRow(uiSoundId);
if (drUISound == null)
{
Log.Warning("Can not load UI sound '{0}' from data table.", uiSoundId.ToString());
@@ -87,46 +62,8 @@ namespace StarForce
playSoundParams.Loop = false;
playSoundParams.VolumeInSoundGroup = drUISound.Volume;
playSoundParams.SpatialBlend = 0f;
return soundComponent.PlaySound(AssetUtility.GetUISoundAsset(drUISound.AssetName), "UISound", Constant.AssetPriority.UISoundAsset, playSoundParams, userData);
}
public static bool IsMuted(this SoundComponent soundComponent, string soundGroupName)
{
if (string.IsNullOrEmpty(soundGroupName))
{
Log.Warning("Sound group is invalid.");
return true;
}
ISoundGroup soundGroup = soundComponent.GetSoundGroup(soundGroupName);
if (soundGroup == null)
{
Log.Warning("Sound group '{0}' is invalid.", soundGroupName);
return true;
}
return soundGroup.Mute;
}
public static void Mute(this SoundComponent soundComponent, string soundGroupName, bool mute)
{
if (string.IsNullOrEmpty(soundGroupName))
{
Log.Warning("Sound group is invalid.");
return;
}
ISoundGroup soundGroup = soundComponent.GetSoundGroup(soundGroupName);
if (soundGroup == null)
{
Log.Warning("Sound group '{0}' is invalid.", soundGroupName);
return;
}
soundGroup.Mute = mute;
GameEntry.Setting.SetBool(Utility.Text.Format(Constant.Setting.SoundGroupMuted, soundGroupName), mute);
GameEntry.Setting.Save();
return soundComponent.PlaySound(AssetUtility.GetUISoundAsset(drUISound.AssetName), "SE",
Constant.AssetPriority.UISoundAsset, playSoundParams, userData);
}
public static float GetVolume(this SoundComponent soundComponent, string soundGroupName)
@@ -164,8 +101,8 @@ namespace StarForce
soundGroup.Volume = volume;
GameEntry.Setting.SetFloat(Utility.Text.Format(Constant.Setting.SoundGroupVolume, soundGroupName), volume);
GameEntry.Setting.SetFloat($"Setting.{soundGroup}Volume", volume);
GameEntry.Setting.Save();
}
}
}
}