Now Audio Playing
This commit is contained in:
1 parent
b7527d8d68
commit
513d6d0bc5
62 files changed
+1168
-119
No files matched your search
@@ -0,0 +1,16 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: dea69d41f90c6ea4fa55c27c1d60c145, type: 3}
|
||||
m_Name: AddressableAssetGroupSortSettings
|
||||
m_EditorClassIdentifier: Unity.Addressables.Editor::UnityEditor.AddressableAssets.Settings.GroupSchemas.AddressableAssetGroupSortSettings
|
||||
sortOrder:
|
||||
- d790534e015d692428ac5a9ce7d2ceb6
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d4769b93af55e1195a9506acfa3d9c28
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -15,7 +15,7 @@ MonoBehaviour:
|
||||
m_DefaultGroup: d790534e015d692428ac5a9ce7d2ceb6
|
||||
m_currentHash:
|
||||
serializedVersion: 2
|
||||
Hash: e468f985d563957211af2aa30c8022ce
|
||||
Hash: 5c0b3de6b8f117471ad9b1bb8d9f282a
|
||||
m_OptimizeCatalogSize: 0
|
||||
m_BuildRemoteCatalog: 0
|
||||
m_CatalogRequestsTimeout: 0
|
||||
@@ -104,6 +104,8 @@ MonoBehaviour:
|
||||
- CameraConfig
|
||||
- UIPanelConfig
|
||||
- PostProccessVolume
|
||||
- AudioInfoConfig
|
||||
- AudioSettingsConfig
|
||||
m_SchemaTemplates: []
|
||||
m_GroupTemplateObjects:
|
||||
- {fileID: 11400000, guid: af0b5782a0090884db056705d7776701, type: 2}
|
||||
|
||||
@@ -15,6 +15,11 @@ MonoBehaviour:
|
||||
m_GroupName: Default Local Group
|
||||
m_GUID: d790534e015d692428ac5a9ce7d2ceb6
|
||||
m_SerializeEntries:
|
||||
- m_GUID: 0f5388dd5b953e74281733a43c9bca5a
|
||||
m_Address: Audio/UI/01. Wake Up, Get Up, Get Out There
|
||||
m_ReadOnly: 0
|
||||
m_SerializedLabels: []
|
||||
FlaggedDuringContentUpdateRestriction: 0
|
||||
- m_GUID: 13852bf3f3ccace4e9deefd844eebb23
|
||||
m_Address: Assets/Resources_moved/UI/Panels/LoadingPanel.prefab
|
||||
m_ReadOnly: 0
|
||||
@@ -25,6 +30,11 @@ MonoBehaviour:
|
||||
m_ReadOnly: 0
|
||||
m_SerializedLabels: []
|
||||
FlaggedDuringContentUpdateRestriction: 0
|
||||
- m_GUID: 2471ee3760db4ecfe8c313bb2c00daf0
|
||||
m_Address: Assets/Resources_moved/Configs/Audio/Audio Source.prefab
|
||||
m_ReadOnly: 0
|
||||
m_SerializedLabels: []
|
||||
FlaggedDuringContentUpdateRestriction: 0
|
||||
- m_GUID: 30778c5a4d5c3f74bac4e5340344cdad
|
||||
m_Address: Assets/Resources_moved/Configs/Volumes/MenuRetro.asset
|
||||
m_ReadOnly: 0
|
||||
@@ -49,11 +59,24 @@ MonoBehaviour:
|
||||
m_SerializedLabels:
|
||||
- SceneConfig
|
||||
FlaggedDuringContentUpdateRestriction: 0
|
||||
- m_GUID: 4bf97e6c7f046f849912182e4ded6c9e
|
||||
m_Address: Assets/Resources_moved/Configs/Audio/Settings/AudioSourceSettingsConfig
|
||||
1.asset
|
||||
m_ReadOnly: 0
|
||||
m_SerializedLabels:
|
||||
- AudioSettingsConfig
|
||||
FlaggedDuringContentUpdateRestriction: 0
|
||||
- m_GUID: 4fcdb7f979b60194db1fb5c03b81bf8c
|
||||
m_Address: UI/Panels/LoadingPanel
|
||||
m_ReadOnly: 0
|
||||
m_SerializedLabels: []
|
||||
FlaggedDuringContentUpdateRestriction: 0
|
||||
- m_GUID: 62388720cc90ef87f9d8ed5328dbc6fe
|
||||
m_Address: Assets/Resources_moved/Configs/Audio/AudioInfoConfig.asset
|
||||
m_ReadOnly: 0
|
||||
m_SerializedLabels:
|
||||
- AudioInfoConfig
|
||||
FlaggedDuringContentUpdateRestriction: 0
|
||||
- m_GUID: 86d0b6ef35383e7409df5a352637fea7
|
||||
m_Address: UI/Panels/SceneSelectPanel
|
||||
m_ReadOnly: 0
|
||||
@@ -100,6 +123,11 @@ MonoBehaviour:
|
||||
m_ReadOnly: 0
|
||||
m_SerializedLabels: []
|
||||
FlaggedDuringContentUpdateRestriction: 0
|
||||
- m_GUID: d7dd69cfadda3d6e18ec390724be0d80
|
||||
m_Address: Assets/Resources_moved/Configs/Audio/AudioSourcePrefabConfig.asset
|
||||
m_ReadOnly: 0
|
||||
m_SerializedLabels: []
|
||||
FlaggedDuringContentUpdateRestriction: 0
|
||||
- m_GUID: d87857258eeea2345a3b926b3c671002
|
||||
m_Address: Assets/Resources_moved/Configs/UI/Loading.asset
|
||||
m_ReadOnly: 0
|
||||
@@ -127,6 +155,12 @@ MonoBehaviour:
|
||||
m_SerializedLabels:
|
||||
- UIPanelConfig
|
||||
FlaggedDuringContentUpdateRestriction: 0
|
||||
- m_GUID: ec0362c4c0d045cccbe89aee2231c3be
|
||||
m_Address: Assets/Resources_moved/Configs/Audio/Settings/AudioSourceSettingsConfig.asset
|
||||
m_ReadOnly: 0
|
||||
m_SerializedLabels:
|
||||
- AudioSettingsConfig
|
||||
FlaggedDuringContentUpdateRestriction: 0
|
||||
- m_GUID: f146779bcd07c524097072c871162bff
|
||||
m_Address: Assets/Resources_moved/Configs/Camera/FPSConfig.asset
|
||||
m_ReadOnly: 0
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5313cc04f8ca14597b338b65bee3093d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,3 +1,4 @@
|
||||
using Code.Infrastructure.Audio;
|
||||
using Code.Infrastructure.Camera;
|
||||
using Code.Infrastructure.UI;
|
||||
using Reflex.Attributes;
|
||||
@@ -16,6 +17,8 @@ namespace Code.Infrastructure.App
|
||||
[Inject] public SceneLoader.SceneLoader SceneLoader { get; set; }
|
||||
[Inject] public CameraStateMachine Camera { get; set; }
|
||||
[Inject] public IUIService UIService { get; set; }
|
||||
[Inject] public IAudioFactory AudioFactory { get; set; }
|
||||
[Inject] public IAudioService AudioService { get; set; }
|
||||
}
|
||||
|
||||
[Generators.StateMachine(typeof(AppStateMachineContext),typeof(AppStates))]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Code.Infrastructure.Audio;
|
||||
using Code.Infrastructure.Camera;
|
||||
using Code.Infrastructure.Configs;
|
||||
using Code.Infrastructure.Input;
|
||||
@@ -21,7 +22,9 @@ namespace Code.Infrastructure.App
|
||||
IUIInitializedHandle,
|
||||
IUIPanelLoaded,
|
||||
IVolumesInitializedHandle,
|
||||
IVolumeLoaded
|
||||
IVolumeLoaded,
|
||||
IAudioSourcePoolInitializedHandle,
|
||||
IAudioConfigsLoadedHandle
|
||||
{
|
||||
public void InstallBindings(ContainerBuilder containerBuilder)
|
||||
{
|
||||
@@ -51,6 +54,13 @@ namespace Code.Infrastructure.App
|
||||
containerBuilder.RegisterType(typeof(VolumeFactory), new[] { typeof(IVolumeFactory) }, Lifetime.Singleton,
|
||||
Resolution.Eager);
|
||||
|
||||
containerBuilder.RegisterType(typeof(AudioFactory), new[] { typeof(IAudioFactory) }, Lifetime.Singleton,
|
||||
Resolution.Eager);
|
||||
containerBuilder.RegisterType(typeof(AudioSourcePool), new[] { typeof(IAudioSourcePool) }, Lifetime.Singleton,
|
||||
Resolution.Eager);
|
||||
containerBuilder.RegisterType(typeof(AudioService), new[] { typeof(IAudioService) }, Lifetime.Singleton,
|
||||
Resolution.Eager);
|
||||
|
||||
// UIFactory
|
||||
// Logo
|
||||
// Scene configs
|
||||
@@ -58,7 +68,9 @@ namespace Code.Infrastructure.App
|
||||
// Camera
|
||||
// Volume Factory
|
||||
// Loading volume
|
||||
_initialLoading = new Loading(7, () => EssentialLoadEnded(_thatRightContainer));
|
||||
// Audio Factory
|
||||
// Audio Pool
|
||||
_initialLoading = new Loading(9, () => EssentialLoadEnded(_thatRightContainer));
|
||||
_ui2CamLoading = new Loading(2,
|
||||
() =>
|
||||
{
|
||||
@@ -156,5 +168,15 @@ namespace Code.Infrastructure.App
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void AudioSourcePoolInitialized()
|
||||
{
|
||||
_initialLoading.DoProgress();
|
||||
}
|
||||
|
||||
public void AudioConfigsLoaded()
|
||||
{
|
||||
_initialLoading.DoProgress();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,13 @@
|
||||
using Code.Infrastructure.Camera;
|
||||
using Code.Infrastructure.Audio;
|
||||
using Code.Infrastructure.Generators;
|
||||
using Code.Infrastructure.SceneLoader;
|
||||
using Code.Infrastructure.UI;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace Code.Infrastructure.App.States
|
||||
{
|
||||
[State(typeof(AppStates),typeof(AppStateMachineContext))]
|
||||
[StateRaisingEvent]
|
||||
public partial class BootstrapState : IOnGameplaySceneLoadedHandler, IUIPanelLoaded
|
||||
public partial class BootstrapState : IOnGameplaySceneLoadedHandler, IUIPanelLoaded, IReadyToPlayHandle
|
||||
{
|
||||
private EventBus.EventBus _eventBus;
|
||||
public BootstrapState(AppStateMachineContext context, EventBus.EventBus eventBus) : base(context,eventBus)
|
||||
@@ -24,11 +21,13 @@ namespace Code.Infrastructure.App.States
|
||||
_eventBus.Subscribe(this);
|
||||
|
||||
Context.UIService.TryLoadPanel(UIPanelType.DebugSceneChooser);
|
||||
Context.AudioFactory.LoadAudioClips(AudioNames.UISounds);
|
||||
// Context.SceneLoader.LoadSceneAsync(SceneId.Gameplay, LoadSceneMode.Single).Forget();
|
||||
}
|
||||
|
||||
protected override void OnExitState()
|
||||
{
|
||||
Context.AudioFactory.ReleaseAudios(AudioNames.UISounds);
|
||||
Context.UIService.TryRemovePanel(UIPanelType.DebugSceneChooser);
|
||||
_eventBus.Unsubscribe(this);
|
||||
}
|
||||
@@ -44,5 +43,10 @@ namespace Code.Infrastructure.App.States
|
||||
|
||||
Context.UIService.OpenPanel(uiPanelType);
|
||||
}
|
||||
|
||||
public void OnReadyToPlay(AudioNames groupName)
|
||||
{
|
||||
Context.AudioService.PlayTest();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,102 @@
|
||||
namespace DefaultNamespace
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Code.Infrastructure.Configs;
|
||||
using Code.Infrastructure.EventBus;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
|
||||
namespace Code.Infrastructure.Audio
|
||||
{
|
||||
public class AudioFactory
|
||||
public interface IAudioFactory
|
||||
{
|
||||
UniTaskVoid LoadAudioClips(AudioNames groupName);
|
||||
void ReleaseAudios(AudioNames groupName);
|
||||
}
|
||||
|
||||
public class AudioFactory : IAudioFactory, IDisposable
|
||||
{
|
||||
private string _label;
|
||||
private Dictionary<AudioNames, Dictionary<int, AssetReference>> _audioInfos = new();
|
||||
|
||||
private Dictionary<AudioNames, Dictionary<int, AsyncOperationHandle<AudioClip>>> _clipsHandles = new();
|
||||
private AsyncOperationHandle<IList<AudioInfoConfig>> _configsHandle;
|
||||
private EventBus.EventBus _eventBus;
|
||||
|
||||
public AudioFactory(IConfigLocator configLocator, EventBus.EventBus eventBus)
|
||||
{
|
||||
_eventBus = eventBus;
|
||||
_label = configLocator.TryGetManyConfigAssetReferences<AudioInfoConfig>();
|
||||
|
||||
for (var i = 0; i < typeof(AudioNames).GetEnumValues().Length; i++)
|
||||
{
|
||||
_audioInfos.Add((AudioNames)i, new Dictionary<int, AssetReference>());
|
||||
_clipsHandles.Add((AudioNames)i, new Dictionary<int, AsyncOperationHandle<AudioClip>>());
|
||||
}
|
||||
|
||||
LoadConfigs().Forget();
|
||||
}
|
||||
|
||||
private async UniTaskVoid LoadConfigs()
|
||||
{
|
||||
_configsHandle = Addressables.LoadAssetsAsync<AudioInfoConfig>(_label);
|
||||
|
||||
await _configsHandle.ToUniTask();
|
||||
|
||||
foreach (AudioInfoConfig config in _configsHandle.Result)
|
||||
_audioInfos[config.GroupName].Add(config.id, config.fileReference);
|
||||
|
||||
_eventBus.RaiseEvent<IAudioConfigsLoadedHandle>(ui => ui.AudioConfigsLoaded());
|
||||
}
|
||||
|
||||
public async UniTaskVoid LoadAudioClips(AudioNames groupName)
|
||||
{
|
||||
foreach (var audioInfo in _audioInfos[groupName])
|
||||
if (!_clipsHandles[groupName].ContainsKey(audioInfo.Key))
|
||||
_clipsHandles[groupName].Add(audioInfo.Key, Addressables.LoadAssetAsync<AudioClip>(audioInfo.Value));
|
||||
else
|
||||
_clipsHandles[groupName][audioInfo.Key] = Addressables.LoadAssetAsync<AudioClip>(audioInfo.Value);
|
||||
|
||||
foreach (var handle in _clipsHandles[groupName])
|
||||
await handle.Value.ToUniTask();
|
||||
|
||||
_eventBus.RaiseEvent<IAudioClipsEventHandle>(ui =>
|
||||
ui.AudioClipsLoaded(groupName, _clipsHandles[groupName].ToDictionary(
|
||||
x => x.Key,
|
||||
x => x.Value.Result)));
|
||||
}
|
||||
|
||||
public void ReleaseAudios(AudioNames groupName)
|
||||
{
|
||||
_eventBus.RaiseEvent<IAudioClipsEventHandle>(x=> x.AudioClipsUnLoaded(groupName));
|
||||
|
||||
foreach (var handle in _clipsHandles)
|
||||
Addressables.Release(handle.Value);
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
foreach (var handles in _clipsHandles)
|
||||
{
|
||||
foreach (var handle in handles.Value)
|
||||
{
|
||||
handle.Value.Release();
|
||||
}
|
||||
}
|
||||
|
||||
_configsHandle.Release();
|
||||
}
|
||||
}
|
||||
|
||||
internal interface IAudioConfigsLoadedHandle : IGlobalSubscriber
|
||||
{
|
||||
void AudioConfigsLoaded();
|
||||
}
|
||||
|
||||
internal interface IAudioClipsEventHandle : IGlobalSubscriber
|
||||
{
|
||||
void AudioClipsLoaded(AudioNames groupName, Dictionary<int, AudioClip> toDictionary);
|
||||
void AudioClipsUnLoaded(AudioNames groupName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using Code.Infrastructure.Generators;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
namespace Code.Infrastructure.Audio
|
||||
{
|
||||
[Config("Configs/Audio/AudioInfo", true)]
|
||||
public class AudioInfo
|
||||
{
|
||||
[ToConfig] public AudioNames GroupName;
|
||||
[ToConfig] public int id;
|
||||
[ToConfig] public AssetReference fileReference;
|
||||
}
|
||||
[Config("Configs/Audio/AudioSource")]
|
||||
public class AudioSourcePrefab
|
||||
{
|
||||
[ToConfig] public AssetReference prefabReference;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 821f8c193f8846568335e415bf1e7ced
|
||||
timeCreated: 1769437653
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Code.Infrastructure.Audio
|
||||
{
|
||||
public enum AudioNames
|
||||
{
|
||||
UISounds,
|
||||
EnemySFX
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 88f7326e5bec4c97b2a70228dcd9f899
|
||||
timeCreated: 1769437552
|
||||
@@ -0,0 +1,54 @@
|
||||
using System.Collections.Generic;
|
||||
using Code.Infrastructure.EventBus;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.Infrastructure.Audio
|
||||
{
|
||||
public interface IAudioService
|
||||
{
|
||||
AudioClip GetClip(AudioNames groupName, int id);
|
||||
void PlayTest();
|
||||
}
|
||||
|
||||
public class AudioService : IAudioClipsEventHandle, IAudioService
|
||||
{
|
||||
private EventBus.EventBus _eventBus;
|
||||
private IAudioFactory _audioFactory;
|
||||
private IAudioSourcePool _pool;
|
||||
private Dictionary<AudioNames, Dictionary<int, AudioClip>> _audioClips = new();
|
||||
|
||||
public AudioService(EventBus.EventBus eventBus, IAudioFactory audioFactory, IAudioSourcePool pool)
|
||||
{
|
||||
_eventBus = eventBus;
|
||||
_audioFactory = audioFactory;
|
||||
_pool = pool;
|
||||
|
||||
_eventBus.Subscribe(this);
|
||||
|
||||
for (int i = 0; i < typeof(AudioNames).GetEnumValues().Length; i++)
|
||||
_audioClips.Add((AudioNames)i, new Dictionary<int, AudioClip>());
|
||||
}
|
||||
|
||||
public void PlayTest()
|
||||
{
|
||||
_pool.GetSource(AudioSourceType.NoBlend).PlayOneShot(GetClip(AudioNames.UISounds, 0));
|
||||
}
|
||||
public AudioClip GetClip(AudioNames groupName, int id) => _audioClips[groupName][id];
|
||||
|
||||
public void AudioClipsLoaded(AudioNames groupname, Dictionary<int, AudioClip> clips)
|
||||
{
|
||||
_audioClips[groupname] = clips;
|
||||
_eventBus.RaiseEvent<IReadyToPlayHandle>(x=> x.OnReadyToPlay(groupname));
|
||||
}
|
||||
|
||||
public void AudioClipsUnLoaded(AudioNames groupName)
|
||||
{
|
||||
_audioClips[groupName] = null;
|
||||
}
|
||||
}
|
||||
|
||||
public interface IReadyToPlayHandle : IGlobalSubscriber
|
||||
{
|
||||
void OnReadyToPlay(AudioNames groupName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e8426c9e925a431aa73069c49d6a71c0
|
||||
timeCreated: 1769446252
|
||||
@@ -0,0 +1,179 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Code.Infrastructure.Configs;
|
||||
using Code.Infrastructure.EventBus;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.Audio;
|
||||
using UnityEngine.Pool;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace Code.Infrastructure.Audio
|
||||
{
|
||||
public interface IAudioSourcePool
|
||||
{
|
||||
AudioSource GetSource(AudioSourceType sourceType);
|
||||
void ReleaseSource(AudioSource source);
|
||||
}
|
||||
|
||||
public class AudioSourcePool : IAudioSourcePool, IDisposable
|
||||
{
|
||||
// The pool holds plain GameObjects (you can swap this for any component type).
|
||||
private IObjectPool<AudioSource> _pool;
|
||||
private GameObject _sourcePrefab;
|
||||
|
||||
private Dictionary<AudioSourceType, AudioSourceSettingsConfig> _settings;
|
||||
|
||||
public AudioSourcePool(Dictionary<AudioSourceType, AudioSourceSettingsConfig> settings) => _settings = settings;
|
||||
|
||||
private string _configsLabel;
|
||||
private AsyncOperationHandle<IList<AudioSourceSettingsConfig>> _handles;
|
||||
private AssetReference _sourcePrefabConfigReference;
|
||||
private AsyncOperationHandle<AudioSourcePrefabConfig> _prefabConfigHandle;
|
||||
private AsyncOperationHandle<GameObject> _prefabHandle;
|
||||
private EventBus.EventBus _eventBus;
|
||||
|
||||
public AudioSourcePool(IConfigLocator configLocator, EventBus.EventBus eventBus)
|
||||
{
|
||||
_eventBus = eventBus;
|
||||
|
||||
_configsLabel = configLocator.TryGetManyConfigAssetReferences<AudioSourceSettingsConfig>();
|
||||
_sourcePrefabConfigReference = configLocator.TryGetConfigAssetReference<AudioSourcePrefabConfig>();
|
||||
|
||||
LoadConfigs().Forget();
|
||||
}
|
||||
|
||||
private async UniTaskVoid LoadConfigs()
|
||||
{
|
||||
_prefabConfigHandle = Addressables.LoadAssetAsync<AudioSourcePrefabConfig>(_sourcePrefabConfigReference);
|
||||
_handles = Addressables.LoadAssetsAsync<AudioSourceSettingsConfig>(_configsLabel);
|
||||
|
||||
await UniTask.WhenAll(
|
||||
_prefabConfigHandle.ToUniTask(),
|
||||
_handles.ToUniTask());
|
||||
|
||||
_prefabHandle = Addressables.LoadAssetAsync<GameObject>(_prefabConfigHandle.Result.prefabReference);
|
||||
|
||||
_settings = _handles.Result.ToDictionary(x => x.sourceType);
|
||||
|
||||
await _prefabHandle.ToUniTask();
|
||||
|
||||
_pool = new ObjectPool<AudioSource>(
|
||||
createFunc: CreateItem,
|
||||
// actionOnGet: OnGet,
|
||||
actionOnRelease: OnRelease,
|
||||
actionOnDestroy: OnDestroyItem,
|
||||
collectionCheck: true, // helps catch double-release mistakes
|
||||
defaultCapacity: 10,
|
||||
maxSize: 20
|
||||
);
|
||||
|
||||
_eventBus.RaiseEvent<IAudioSourcePoolInitializedHandle>(x => x.AudioSourcePoolInitialized());
|
||||
}
|
||||
// Creates a new pooled GameObject the first time (and whenever the pool needs more).
|
||||
private AudioSource CreateItem()
|
||||
{
|
||||
var audioSource = Object.Instantiate(_prefabHandle.Result).GetComponent<AudioSource>();
|
||||
audioSource.name = "PooledAudioSource";
|
||||
Object.DontDestroyOnLoad(audioSource);
|
||||
return audioSource;
|
||||
}
|
||||
|
||||
// Called when an item is taken from the pool.
|
||||
private void OnGet(AudioSource source)
|
||||
{
|
||||
//source.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
// Called when an item is returned to the pool.
|
||||
private void OnRelease(AudioSource source)
|
||||
{
|
||||
source.Stop();
|
||||
//source.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// Called when the pool decides to destroy an item (e.g., above max size).
|
||||
private void OnDestroyItem(AudioSource source)
|
||||
{
|
||||
Object.Destroy(source.gameObject);
|
||||
}
|
||||
//
|
||||
// public async UniTaskVoid PlayOneShot(AudioClip clip, Vector3 position, AudioMixerGroup audioMixerGroup, AudioSourceType audioSourceType = AudioSourceType.NoBlend, Action onComplete = null)
|
||||
// {
|
||||
// AudioSource source = _pool.Get();
|
||||
// source.PlayOneShot(clip);
|
||||
// source.spatialBlend = _settings[audioSourceType].spatialBlend;
|
||||
// source.transform.position = position;
|
||||
// source.outputAudioMixerGroup = audioMixerGroup;
|
||||
//
|
||||
// await UniTask.WaitUntilValueChanged(source, x => x.isPlaying);
|
||||
// onComplete?.Invoke();
|
||||
// _pool.Release(source);
|
||||
// }
|
||||
// public async UniTaskVoid PlayOneShot(AudioClip clip, AudioMixerGroup audioMixerGroup, AudioSourceType audioSourceType = AudioSourceType.NoBlend, Action onComplete = null)
|
||||
// {
|
||||
// AudioSource source = _pool.Get();
|
||||
// source.PlayOneShot(clip);
|
||||
// source.spatialBlend = _settings[audioSourceType].spatialBlend;
|
||||
// source.outputAudioMixerGroup = audioMixerGroup;
|
||||
//
|
||||
// await UniTask.WaitUntilValueChanged(source, x => x.isPlaying);
|
||||
// onComplete?.Invoke();
|
||||
// _pool.Release(source);
|
||||
// }
|
||||
// public async UniTaskVoid PlayOneShot(AudioSource audioSource, AudioClip clip, AudioMixerGroup audioMixerGroup, AudioSourceType audioSourceType = AudioSourceType.NoBlend, Action onComplete = null)
|
||||
// {
|
||||
// audioSource.PlayOneShot(clip);
|
||||
// audioSource.spatialBlend = _settings[audioSourceType].spatialBlend;
|
||||
// audioSource.outputAudioMixerGroup = audioMixerGroup;
|
||||
//
|
||||
// // TODO Потом сделать. Можно с cancellation, но сейчас лень. Ну правда
|
||||
// await UniTask.WaitUntilValueChanged(audioSource, x => x.isPlaying);
|
||||
//
|
||||
// if (!audioSource) return;
|
||||
//
|
||||
// _pool.Release(audioSource);
|
||||
// onComplete?.Invoke();
|
||||
// }
|
||||
// public async UniTaskVoid PlayOneShot(AudioClip clip, AudioMixerGroup audioMixerGroup, CancellationTokenSource cancellationToken, AudioSourceType audioSourceType = AudioSourceType.NoBlend, Action onComplete = null)
|
||||
// {
|
||||
// AudioSource source = _pool.Get();
|
||||
// source.PlayOneShot(clip);
|
||||
// source.spatialBlend = _settings[audioSourceType].spatialBlend;
|
||||
// source.outputAudioMixerGroup = audioMixerGroup;
|
||||
//
|
||||
// var (isCanceled, _) = await UniTask.WaitUntilValueChanged(source, x => x.isPlaying, cancellationToken: cancellationToken.Token).SuppressCancellationThrow();
|
||||
//
|
||||
// _pool.Release(source);
|
||||
//
|
||||
// if(!isCanceled) onComplete?.Invoke();
|
||||
// else cancellationToken.Dispose();
|
||||
// }
|
||||
public AudioSource GetSource(AudioSourceType sourceType)
|
||||
{
|
||||
var source = _pool.Get();
|
||||
|
||||
source.spatialBlend = _settings[sourceType].spatialBlend;
|
||||
|
||||
return source;
|
||||
}
|
||||
|
||||
public void ReleaseSource(AudioSource source) => _pool.Release(source);
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Addressables.Release(_handles);
|
||||
Addressables.Release(_prefabConfigHandle);
|
||||
Addressables.Release(_sourcePrefab);
|
||||
}
|
||||
}
|
||||
|
||||
public interface IAudioSourcePoolInitializedHandle : IGlobalSubscriber
|
||||
{
|
||||
void AudioSourcePoolInitialized();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 246ae406fabc4ca791673d3f38cfe1c5
|
||||
timeCreated: 1769448041
|
||||
@@ -0,0 +1,13 @@
|
||||
using Code.Infrastructure.Generators;
|
||||
|
||||
namespace Code.Infrastructure.Audio
|
||||
{
|
||||
[Config("Configs/Audio/AudioSourceSettings", true)]
|
||||
public class AudioSourceSettings
|
||||
{
|
||||
// Дополнять по мере необходимости
|
||||
[ToConfig] public float spatialBlend;
|
||||
|
||||
[ToConfig] public AudioSourceType sourceType;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 76d9dd39cbe641dab0cfa8ed1f2007f4
|
||||
timeCreated: 1769448198
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Code.Infrastructure.Audio
|
||||
{
|
||||
public enum AudioSourceType
|
||||
{
|
||||
Full3D,
|
||||
NoBlend
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 85f9cb99599f4399a1fd66496b5184d0
|
||||
timeCreated: 1769448254
|
||||
@@ -1,6 +1,4 @@
|
||||
using System.ComponentModel;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Code.Infrastructure.UI
|
||||
{
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 13f65a629e8c7e8c4a665474d64bd743
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5dee85ec17f52ef9795843350a175109
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -18,25 +18,33 @@ MonoBehaviour:
|
||||
m_SubObjectType:
|
||||
m_SubObjectGUID:
|
||||
m_EditorAssetChanged: 0
|
||||
CameraSettings: CameraConfig
|
||||
UIPanelSettings: UIPanelConfig
|
||||
GameCamera:
|
||||
m_AssetGUID: c42e39e2fb64cdd45b2ebc4b723d9d0c
|
||||
m_SubObjectName:
|
||||
m_SubObjectType:
|
||||
m_SubObjectGUID:
|
||||
m_EditorAssetChanged: 1
|
||||
CanvasSettings:
|
||||
m_AssetGUID: 17c5e56eb6c99db40b6093c9d543bb4f
|
||||
m_SubObjectName:
|
||||
m_SubObjectType:
|
||||
m_SubObjectGUID:
|
||||
m_EditorAssetChanged: 0
|
||||
GameCamera:
|
||||
m_AssetGUID: c42e39e2fb64cdd45b2ebc4b723d9d0c
|
||||
m_SubObjectName:
|
||||
m_SubObjectType:
|
||||
m_SubObjectGUID:
|
||||
m_EditorAssetChanged: 1
|
||||
InputService:
|
||||
m_AssetGUID: eab71c0cf90c4b94294e497d3734cfe1
|
||||
m_SubObjectName:
|
||||
m_SubObjectType:
|
||||
m_SubObjectGUID:
|
||||
m_EditorAssetChanged: 0
|
||||
AudioSourcePrefab:
|
||||
m_AssetGUID: d7dd69cfadda3d6e18ec390724be0d80
|
||||
m_SubObjectName:
|
||||
m_SubObjectType:
|
||||
m_SubObjectGUID:
|
||||
m_EditorAssetChanged: 1
|
||||
AudioInfo: AudioInfoConfig
|
||||
CameraSettings: CameraConfig
|
||||
UIPanelSettings: UIPanelConfig
|
||||
VolumeSettings: PostProccessVolume
|
||||
AudioSourceSettings: AudioSettingsConfig
|
||||
SceneInfo: SceneConfig
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 71c6e3f3eca713f79aeab6d6d5f97a5c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a2d053908c1e62df3a20c0dc82138a43
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,23 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f5388dd5b953e74281733a43c9bca5a
|
||||
AudioImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 8
|
||||
defaultSettings:
|
||||
serializedVersion: 2
|
||||
loadType: 0
|
||||
sampleRateSetting: 0
|
||||
sampleRateOverride: 44100
|
||||
compressionFormat: 1
|
||||
quality: 1
|
||||
conversionMode: 0
|
||||
preloadAudioData: 0
|
||||
platformSettingOverrides: {}
|
||||
forceToMono: 0
|
||||
normalize: 1
|
||||
loadInBackground: 0
|
||||
ambisonic: 0
|
||||
3D: 1
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8fcdf8416abd923e6bd56b3cae3e64a9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,131 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &8652297258760236330
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 497122190607935989}
|
||||
- component: {fileID: 8953235124198601079}
|
||||
m_Layer: 0
|
||||
m_Name: Audio Source
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &497122190607935989
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8652297258760236330}
|
||||
serializedVersion: 2
|
||||
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: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!82 &8953235124198601079
|
||||
AudioSource:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8652297258760236330}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 4
|
||||
OutputAudioMixerGroup: {fileID: 0}
|
||||
m_audioClip: {fileID: 0}
|
||||
m_Resource: {fileID: 0}
|
||||
m_PlayOnAwake: 1
|
||||
m_Volume: 1
|
||||
m_Pitch: 1
|
||||
Loop: 0
|
||||
Mute: 0
|
||||
Spatialize: 0
|
||||
SpatializePostEffects: 0
|
||||
Priority: 128
|
||||
DopplerLevel: 1
|
||||
MinDistance: 1
|
||||
MaxDistance: 500
|
||||
Pan2D: 0
|
||||
rolloffMode: 0
|
||||
BypassEffects: 0
|
||||
BypassListenerEffects: 0
|
||||
BypassReverbZones: 0
|
||||
rolloffCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
panLevelCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
spreadCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
reverbZoneMixCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2471ee3760db4ecfe8c313bb2c00daf0
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: ba4d0c0f70786a459b739ae33e66122a, type: 3}
|
||||
m_Name: AudioSourcePrefabConfig
|
||||
m_EditorClassIdentifier: Assembly-CSharp::Code.Infrastructure.Audio.AudioSourcePrefabConfig
|
||||
prefabReference:
|
||||
m_AssetGUID: 2471ee3760db4ecfe8c313bb2c00daf0
|
||||
m_SubObjectName:
|
||||
m_SubObjectType:
|
||||
m_SubObjectGUID:
|
||||
m_EditorAssetChanged: 0
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d7dd69cfadda3d6e18ec390724be0d80
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d71926e410ce41907b3cd545595812fb
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,22 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: a8b089dd854c0a084ba749d31f8b399f, type: 3}
|
||||
m_Name: AudioInfoConfig
|
||||
m_EditorClassIdentifier: Assembly-CSharp::Code.Infrastructure.Audio.AudioInfoConfig
|
||||
GroupName: 0
|
||||
id: 0
|
||||
fileReference:
|
||||
m_AssetGUID: 0f5388dd5b953e74281733a43c9bca5a
|
||||
m_SubObjectName:
|
||||
m_SubObjectType:
|
||||
m_SubObjectGUID:
|
||||
m_EditorAssetChanged: 0
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 62388720cc90ef87f9d8ed5328dbc6fe
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: edd23fce0ea3a7aa494e02195d8b3ed4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 85a3854301201dc0d93ecb89c2f30e92, type: 3}
|
||||
m_Name: Full3D
|
||||
m_EditorClassIdentifier: Assembly-CSharp::Code.Infrastructure.Audio.AudioSourceSettingsConfig
|
||||
spatialBlend: 1
|
||||
sourceType: 0
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4bf97e6c7f046f849912182e4ded6c9e
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 85a3854301201dc0d93ecb89c2f30e92, type: 3}
|
||||
m_Name: NoBlend
|
||||
m_EditorClassIdentifier: Assembly-CSharp::Code.Infrastructure.Audio.AudioSourceSettingsConfig
|
||||
spatialBlend: 0
|
||||
sourceType: 1
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ec0362c4c0d045cccbe89aee2231c3be
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
#pragma warning disable CS0105
|
||||
using Code.Infrastructure.Audio;
|
||||
using System;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
namespace Code.Infrastructure.Audio{
|
||||
#pragma warning restore CS0105
|
||||
[CreateAssetMenu(fileName = "AudioInfoConfig", menuName = "Configs/Audio/AudioInfo")]
|
||||
public class AudioInfoConfig : ScriptableObject
|
||||
{
|
||||
public Code.Infrastructure.Audio.AudioNames GroupName;
|
||||
public System.Int32 id;
|
||||
public UnityEngine.AddressableAssets.AssetReference fileReference;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a8b089dd854c0a084ba749d31f8b399f
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
#pragma warning disable CS0105
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
namespace Code.Infrastructure.Audio{
|
||||
#pragma warning restore CS0105
|
||||
[CreateAssetMenu(fileName = "AudioSourcePrefabConfig", menuName = "Configs/Audio/AudioSource")]
|
||||
public class AudioSourcePrefabConfig : ScriptableObject
|
||||
{
|
||||
public UnityEngine.AddressableAssets.AssetReference prefabReference;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ba4d0c0f70786a459b739ae33e66122a
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
#pragma warning disable CS0105
|
||||
using System;
|
||||
using Code.Infrastructure.Audio;
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
namespace Code.Infrastructure.Audio{
|
||||
#pragma warning restore CS0105
|
||||
[CreateAssetMenu(fileName = "AudioSourceSettingsConfig", menuName = "Configs/Audio/AudioSourceSettings")]
|
||||
public class AudioSourceSettingsConfig : ScriptableObject
|
||||
{
|
||||
public System.Single spatialBlend;
|
||||
public Code.Infrastructure.Audio.AudioSourceType sourceType;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 85a3854301201dc0d93ecb89c2f30e92
|
||||
@@ -22,12 +22,12 @@ public partial class AppStateMachine : AbstractStateMachine<Code.Infrastructure.
|
||||
var stateBootstrapState = new BootstrapState(StateMachineContext,eventBus);
|
||||
States.Add(stateBootstrapState.myState, stateBootstrapState);
|
||||
|
||||
var stateGameplayState = new GameplayState(StateMachineContext,eventBus);
|
||||
States.Add(stateGameplayState.myState, stateGameplayState);
|
||||
|
||||
var stateMainMenuState = new MainMenuState(StateMachineContext,eventBus);
|
||||
States.Add(stateMainMenuState.myState, stateMainMenuState);
|
||||
|
||||
var stateGameplayState = new GameplayState(StateMachineContext,eventBus);
|
||||
States.Add(stateGameplayState.myState, stateGameplayState);
|
||||
|
||||
}
|
||||
|
||||
protected override bool CheckTransitionAllowed(Code.Infrastructure.App.AppStates nextState) => AllowedStates.HasFlag(nextState);
|
||||
|
||||
@@ -3,10 +3,13 @@
|
||||
using Code.Infrastructure.UI;
|
||||
using Code.Infrastructure.Camera;
|
||||
using Code.Infrastructure.Input;
|
||||
using Code.Infrastructure.Volume;
|
||||
using Code.Infrastructure.Audio;
|
||||
using Code.Infrastructure.Audio;
|
||||
using Code.Infrastructure.Camera;
|
||||
using Code.Infrastructure.SceneLoader;
|
||||
using Code.Infrastructure.UI;
|
||||
using Code.Infrastructure.Volume;
|
||||
using Code.Infrastructure.Audio;
|
||||
using Code.Infrastructure.SceneLoader;
|
||||
|
||||
using UnityEngine;
|
||||
#pragma warning restore CS0105
|
||||
@@ -20,19 +23,25 @@ using Code.Infrastructure.UI;
|
||||
{
|
||||
SystemConfigsReferences systemConfigsReferences = Resources.Load<SystemConfigsReferences>("SystemConfigsReferences");
|
||||
|
||||
_multipleConfigReferences.Add(typeof(Code.Infrastructure.UI.UIPanelSettingsConfig), systemConfigsReferences.UIPanelSettings);
|
||||
_singleConfigReferences.Add(typeof(Code.Infrastructure.UI.CanvasSettingsConfig), systemConfigsReferences.CanvasSettings);
|
||||
|
||||
_singleConfigReferences.Add(typeof(Code.Infrastructure.Camera.GameCameraConfig), systemConfigsReferences.GameCamera);
|
||||
|
||||
_singleConfigReferences.Add(typeof(Code.Infrastructure.Input.InputServiceConfig), systemConfigsReferences.InputService);
|
||||
|
||||
_multipleConfigReferences.Add(typeof(Code.Infrastructure.Volume.VolumeSettingsConfig), systemConfigsReferences.VolumeSettings);
|
||||
_singleConfigReferences.Add(typeof(Code.Infrastructure.Audio.AudioSourcePrefabConfig), systemConfigsReferences.AudioSourcePrefab);
|
||||
|
||||
_multipleConfigReferences.Add(typeof(Code.Infrastructure.Audio.AudioInfoConfig), systemConfigsReferences.AudioInfo);
|
||||
|
||||
_multipleConfigReferences.Add(typeof(Code.Infrastructure.Camera.CameraSettingsConfig), systemConfigsReferences.CameraSettings);
|
||||
|
||||
_multipleConfigReferences.Add(typeof(Code.Infrastructure.SceneLoader.SceneInfoConfig), systemConfigsReferences.SceneInfo);
|
||||
_multipleConfigReferences.Add(typeof(Code.Infrastructure.UI.UIPanelSettingsConfig), systemConfigsReferences.UIPanelSettings);
|
||||
|
||||
_singleConfigReferences.Add(typeof(Code.Infrastructure.UI.CanvasSettingsConfig), systemConfigsReferences.CanvasSettings);
|
||||
_multipleConfigReferences.Add(typeof(Code.Infrastructure.Volume.VolumeSettingsConfig), systemConfigsReferences.VolumeSettings);
|
||||
|
||||
_multipleConfigReferences.Add(typeof(Code.Infrastructure.Audio.AudioSourceSettingsConfig), systemConfigsReferences.AudioSourceSettings);
|
||||
|
||||
_multipleConfigReferences.Add(typeof(Code.Infrastructure.SceneLoader.SceneInfoConfig), systemConfigsReferences.SceneInfo);
|
||||
|
||||
//_singleConfigReferences.Add(typeof(ScenesAssetReferences), systemConfigsReferences.scenesAssetReferences);
|
||||
}
|
||||
|
||||
@@ -3,10 +3,13 @@
|
||||
using Code.Infrastructure.UI;
|
||||
using Code.Infrastructure.Camera;
|
||||
using Code.Infrastructure.Input;
|
||||
using Code.Infrastructure.Volume;
|
||||
using Code.Infrastructure.Audio;
|
||||
using Code.Infrastructure.Audio;
|
||||
using Code.Infrastructure.Camera;
|
||||
using Code.Infrastructure.SceneLoader;
|
||||
using Code.Infrastructure.UI;
|
||||
using Code.Infrastructure.Volume;
|
||||
using Code.Infrastructure.Audio;
|
||||
using Code.Infrastructure.SceneLoader;
|
||||
|
||||
using UnityEngine.AddressableAssets;
|
||||
#pragma warning restore CS0105
|
||||
@@ -14,13 +17,16 @@ using Code.Infrastructure.UI;
|
||||
namespace Code.Infrastructure.Configs{
|
||||
public partial class SystemConfigsReferences
|
||||
{
|
||||
public string UIPanelSettings;
|
||||
public AssetReference CanvasSettings;
|
||||
public AssetReference GameCamera;
|
||||
public AssetReference InputService;
|
||||
public string VolumeSettings;
|
||||
public AssetReference AudioSourcePrefab;
|
||||
public string AudioInfo;
|
||||
public string CameraSettings;
|
||||
public string UIPanelSettings;
|
||||
public string VolumeSettings;
|
||||
public string AudioSourceSettings;
|
||||
public string SceneInfo;
|
||||
public AssetReference CanvasSettings;
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user