public ISoundManager InitSoundSlot(Func <SoundSlotComponentBase> onCreateSlot, int initializeSize = 0) { if (_slotPool != null) { _slotPool.Dispose(); } _slotPool = new SoundSlotPool(onCreateSlot, initializeSize); _slotPool.SetParents(_monoOwner.transform); return(this); }
public SoundManager(MonoBehaviour owner) { _monoOwner = owner; _slotPool = new SoundSlotPool(() => { SoundSlotComponentBase soundSlotComponent = new GameObject(nameof(SoundSlotComponent)).AddComponent <SoundSlotComponent>(); soundSlotComponent.transform.SetParent(_monoOwner.transform); AudioSource source = soundSlotComponent.gameObject.GetComponent <AudioSource>(); source.playOnAwake = false; return(soundSlotComponent); }); _slotPool.SetParents(_monoOwner.transform); }
public SoundManager(MonoBehaviour owner, Func <SoundSlotComponentBase> onCreateSlot) { _monoOwner = owner; _slotPool = new SoundSlotPool(onCreateSlot); // NOTE fail test case, _slotPool.SetParents(_monoOwner.transform); }