CustomUtils Help

Sound

프로젝트 바로 가기

소스 코드 바로 가기

Sound Class Diagram
NewSoundSoundBaseSoundCoreBase soundCoreEnum masterEnumEnum representControlEnumvoid UpdateSoundAssetInfo(SoundAssetInfo info)void PlayRefresh();void SubmitSoundOrder(SoundOrder order)NewSoundCoreSoundCoreBaseDictionary<Enum, List<SoundAssetInfo>> _cacheSoundInfoDic;AudioMixer _audioMixer;Enum _currentSnapshotType;AudioMixer LoadAudioMixer()List<SoundAssetInfo> LoadSoundAssetInfoList()«record»SoundAssetInfopublic string pathpublic string name«Sample»SomeSoundInteractionInterfaceSoundCoreBase soundCoreList<SoundBase> soundListvoid Play()void Stop()Some Method«ScriptableObject»SoundTrackSoundTrackEvent[] eventListSoundTrackEventAudioClip clip0..*10..*0..*0..*

SoundCoreBase

사운드 처리에 필요한 AudioMixer 기반 기초 시스템 및 관련 메타 데이터 처리 인터페이스 제공

SoundCoreBase
  • AudioMixer 관리

  • Sanpshot 기능 통합 처리

  • SoundAssetInfo를 통한 리소스 메타 데이터 제공

SoundAssetInfo
  • 사운드 명칭 및 경로 제공

public abstract class SoundCoreBase : MonoBehaviour { // Fields.. private void Awake() { _audioMixer = LoadAudioMixer(); if (_audioMixer == null) { Logger.TraceError($"Missing {nameof(_audioMixer)}. Check {nameof(LoadAudioMixer)} Method"); return; } //... } protected virtual void CacheSoundInfo() { var infoList = LoadSoundAssetInfoList(); //... } protected abstract AudioMixer LoadAudioMixer(); protected abstract List<SoundAssetInfo> LoadSoundAssetInfoList(); // Methods.. }
public record SoundAssetInfo { public string path; public string name; public SoundAssetInfo(string path, string name) { this.path = path; this.name = name; } }

SoundBase

동일 하거나 유사한 범주에 속하는 사운드 집합에 대한 기초 인터페이스. SoundCoreBase 종속성 주입을 통한 모듈화와 SoundOrder 구현으로 통합 처리 인터페이스 제공

SoundBase
  • SoundCoreBase 통해 획득한 리소스 메타 데이터를 기반으로 사운드 리소스 획득 및 제공

  • SoundTrack 관리

  • AudioMixerGroupAudioSource를 동적으로 관리 하여 최적화

  • Queue를 통한 SoundTrack 처리 제공

SoundOrder
  • 통합 처리를 위한 데이터 전달용 추상 record

  • SoundBaseSubmitSoundOrder(SoundOrder order) 구현 필요

[RequiresAttributeImplementation(typeof(MasterSoundAttribute))] [RequiresAttributeImplementation(typeof(ControlSoundAttribute))] public abstract class SoundBase { protected SoundCoreBase soundCore; //... public Enum masterEnum; public Enum representControlEnum; public SoundBase(SoundCoreBase soundCore) { this.soundCore = soundCore; // ... } protected abstract void UpdateSoundAssetInfo(SoundAssetInfo info); public abstract void PlayRefresh(); public abstract void SubmitSoundOrder(SoundOrder order); }
public abstract record SoundOrder { public Enum masterType; public Enum representControlType; public SoundOrder(Enum masterType, Enum representControlType) { this.masterType = masterType; this.representControlType = representControlType; } }

SoundTrack

SoundTrack_01.png

로우 리소스 중복 및 사운드 처리 접근성 향상을 위한 ScriptableObject 기반 Asset 구조

SoundTrack
  • Editor 상에서 테스트 처리 제공

  • 메타 데이터를 통해 그룹화된 사운드 처리 제공

  • AudioSource 검증 및 관리 제공

[CreateAssetMenu(fileName = "SoundTrack", menuName = "Sound/Create SoundTrack")] public class SoundTrack : ScriptableObject { public GlobalEnum<SoundTrackEnumAttribute> trackType = new(); public SoundTrackEvent[] eventList; }
[Serializable] public class SoundTrackEvent { public AudioClip clip; public bool loop = false; public float startTime = 0; public void Unload() public bool IsValidClip() }
public class SoundTrackEnumAttribute : PriorityAttribute { } [SoundTrackEnum(priority = 1)] public enum TEST_SOUND_TRACK_TYPE { TEST_PLAY } [SoundTrackEnum] public enum TRACK_TYPE { DEFAULT, OVERLAP, RANDOM, LIMIT_PLAY, }
Last modified: 01 2월 2025