-
Notifications
You must be signed in to change notification settings - Fork 95
Introduce AudioSystem to write back the current state of an audio source #6135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
m3taphysics
wants to merge
7
commits into
dev
Choose a base branch
from
fix/audio-source-changes
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
93bb6dd
Introduce AudioSystem to write back the current state of an audio source
m3taphysics bfced7d
Tidy up
m3taphysics 7659cf0
Missing files
m3taphysics 8e2ece1
Merge branch 'dev' into fix/audio-source-changes
m3taphysics 787cc40
Update protocol
m3taphysics 4fd64b8
Merge remote-tracking branch 'origin/fix/audio-source-changes' into f…
m3taphysics d9e0f28
Removed enumerator allocation
m3taphysics File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
unity-renderer/Assets/DCLPlugins/ECS7/Systems/AudioSourceSystem.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
...er/Assets/DCLPlugins/ECS7/Systems/AudioSourceSystem/ECS7Plugin.Systems.AudioSource.asmdef
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| { | ||
| "name": "ECS7Plugin.Systems.AudioSource", | ||
| "rootNamespace": "", | ||
| "references": [ | ||
| "GUID:9cccce9925d3495d8a5e4fa5b25f54a5", | ||
| "GUID:9239602a072d4e52b5f1cae20ab2b459", | ||
| "GUID:0a17d39e1dc14c038aa3c6483a185df0", | ||
| "GUID:37d2c04574c1d480d8c817e2a7c578e7", | ||
| "GUID:97d8897529779cb49bebd400c7f402a6", | ||
| "GUID:ac62e852826a4b36aeb22931dad73edb", | ||
| "GUID:1e10040ab6604cbe8ad0921047d49e65", | ||
| "GUID:a881b57670b1d2747a6d7f9e32b63230", | ||
| "GUID:3c7b57a14671040bd8c549056adc04f5", | ||
| "GUID:acb0f5633d7c47aba96ee6b61c872d94" | ||
| ], | ||
| "includePlatforms": [], | ||
| "excludePlatforms": [], | ||
| "allowUnsafeCode": false, | ||
| "overrideReferences": false, | ||
| "precompiledReferences": [], | ||
| "autoReferenced": true, | ||
| "defineConstraints": [], | ||
| "versionDefines": [], | ||
| "noEngineReferences": false | ||
| } |
3 changes: 3 additions & 0 deletions
3
...sets/DCLPlugins/ECS7/Systems/AudioSourceSystem/ECS7Plugin.Systems.AudioSource.asmdef.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
unity-renderer/Assets/DCLPlugins/ECS7/Systems/AudioSourceSystem/ECSAudioSourceSystem.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| using DCL.ECS7; | ||
| using DCL.ECS7.ComponentWrapper.Generic; | ||
| using DCL.ECS7.InternalComponents; | ||
| using DCL.ECSComponents; | ||
| using System.Collections.Generic; | ||
|
|
||
| namespace ECSSystems.AudioSourceSystem | ||
| { | ||
| public class ECSAudioSourceSystem | ||
| { | ||
| private readonly IInternalECSComponent<InternalAudioSource> audioSourceComponent; | ||
| private readonly IReadOnlyDictionary<int, ComponentWriter> componentsWriter; | ||
| private readonly WrappedComponentPool<IWrappedComponent<PBAudioSource>> audioSourcePool; | ||
|
|
||
| public ECSAudioSourceSystem( | ||
| IInternalECSComponent<InternalAudioSource> audioSourceComponent, | ||
| IReadOnlyDictionary<int, ComponentWriter> componentsWriter, | ||
| WrappedComponentPool<IWrappedComponent<PBAudioSource>> audioSourcePool) | ||
| { | ||
| this.audioSourceComponent = audioSourceComponent; | ||
| this.componentsWriter = componentsWriter; | ||
| this.audioSourcePool = audioSourcePool; | ||
| } | ||
|
|
||
| public void Update() | ||
| { | ||
| var audioSourceComponentList = audioSourceComponent.GetForAll(); | ||
|
|
||
| // Loop through every audio source component | ||
| for(var i = 0; i < audioSourceComponentList.Count; i++) | ||
| { | ||
| var component = audioSourceComponentList[i]; | ||
| var scene = component.key1; | ||
| long entity = component.key2; | ||
| var model = component.value.model; | ||
|
|
||
| if (!componentsWriter.TryGetValue(scene.sceneData.sceneNumber, out var writer)) continue; | ||
| var wrappedComponent = audioSourcePool.Get(); | ||
| wrappedComponent.WrappedComponent.Model.Playing = model.audioSource.isPlaying; | ||
| wrappedComponent.WrappedComponent.Model.Loop = model.loop; | ||
| wrappedComponent.WrappedComponent.Model.Volume = model.volume; | ||
| wrappedComponent.WrappedComponent.Model.Pitch = model.pitch; | ||
| wrappedComponent.WrappedComponent.Model.AudioClipUrl ??= model.audioClipUrl; | ||
| wrappedComponent.WrappedComponent.Model.CurrentTime = model.audioSource.time; | ||
| writer.Put(entity, ComponentID.AUDIO_SOURCE, wrappedComponent); | ||
| } | ||
| } | ||
| } | ||
| } |
3 changes: 3 additions & 0 deletions
3
unity-renderer/Assets/DCLPlugins/ECS7/Systems/AudioSourceSystem/ECSAudioSourceSystem.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.