audio fixes

This commit is contained in:
Savya Bikram Shah
2026-05-29 19:12:23 +05:45
parent 41c9969996
commit 84689a6755
3 changed files with 22 additions and 3 deletions

View File

@@ -16,8 +16,17 @@ namespace Darkmatter.Services.Audio
{
if (sfxCatalog != null)
builder.RegisterComponent(sfxCatalog);
if (audioService != null)
builder.RegisterComponent<IAudioService>(audioService);
var resolved = audioService;
if (resolved == null) resolved = GetComponent<AudioService>();
if (resolved == null) resolved = GetComponentInChildren<AudioService>(includeInactive: true);
if (resolved == null) resolved = FindFirstObjectByType<AudioService>(FindObjectsInactive.Include);
if (resolved != null)
builder.RegisterComponent<IAudioService>(resolved);
else
Debug.LogError("[AudioServiceModule] No AudioService component found. SFX/music won't play. Assign 'audioService' field or add AudioService MonoBehaviour to scene.");
builder.Register<ISfxPlayer, SfxPlayer>(Lifetime.Singleton);
}
}

View File

@@ -72,8 +72,18 @@ namespace Darkmatter.Services.Audio
private Dictionary<AudioChannel, AudioMixerGroup> _mixerGroups;
private float[] _currentWeights;
private bool _initialized;
private void Awake()
{
InitializeAsync(default).Forget();
}
public UniTask InitializeAsync(CancellationToken cancellationToken)
{
if (_initialized) return UniTask.CompletedTask;
_initialized = true;
if (sourceRoot == null) sourceRoot = transform;
_lifetimeCts = new CancellationTokenSource();

View File

@@ -12,7 +12,7 @@ PlayerSettings:
targetDevice: 2
useOnDemandResources: 0
accelerometerFrequency: 60
companyName: Darkmatter
companyName: Darkmatter Game Production
productName: 'Colorbook : Draw and Learn'
defaultCursor: {fileID: 0}
cursorHotspot: {x: 0, y: 0}