public void StopAudioSource(AudioSource audioSource) { if (audioSource) { audioSource.loop = false; audioSource.Pause(); audioSourcePool.Release(audioSource); } }
public void should_nullify_class_based_components_on_release() { var componentPool = new ComponentPool <TestComponentOne>(10); var indexToUse = componentPool.IndexPool.AllocateInstance(); componentPool.Components[indexToUse] = new TestComponentOne(); componentPool.Release(indexToUse); Assert.True(componentPool.Components.All(x => x is null)); }
public void should_dispose_disposable_component_on_release() { var componentPool = new ComponentPool <TestDisposableComponent>(10); var indexToUse = componentPool.IndexPool.AllocateInstance(); var componentToUse = new TestDisposableComponent(); componentPool.Components[indexToUse] = componentToUse; componentPool.Release(indexToUse); Assert.True(componentToUse.isDisposed); }
public void should_request_index_pool_release_when_releasing_component() { var componentPool = new ComponentPool <TestStructComponentOne>(10); var indexToUse = componentPool.IndexPool.AllocateInstance(); var availableIndexesPrior = componentPool.IndexPool.AvailableIndexes.ToArray(); componentPool.Release(indexToUse); var availableIndexesAfter = componentPool.IndexPool.AvailableIndexes.ToArray(); Assert.NotSame(availableIndexesPrior, availableIndexesAfter); Assert.DoesNotContain(indexToUse, availableIndexesPrior); Assert.Contains(indexToUse, availableIndexesAfter); }