Introduce AudioSystem to write back the current state of an audio source#6135
Introduce AudioSystem to write back the current state of an audio source#6135m3taphysics wants to merge 7 commits intodevfrom
Conversation
|
After the CI passes: WebThis branch can be previewed at:
Desktop:If you have the launcher installed (download launcher) you can press open on the following link: SDK 6/7:More |
| using DCL.ECSRuntime; | ||
| using RPC.Context; | ||
| using System.Collections.Generic; | ||
| using UnityEngine; |
There was a problem hiding this comment.
Maybe this is a leftover?
| using DCL.Helpers; | ||
| using DCL.Models; | ||
| using DCL.SettingsCommon; | ||
| using System.Collections.Generic; |
There was a problem hiding this comment.
I think using Cysharp.Threading.Tasks; and using System.Collections.Generic; are not needed, maybe a left over?
| using DCL.ECSComponents; | ||
| using DCL.ECSRuntime; | ||
| using System.Collections.Generic; | ||
| using UnityEngine; |
There was a problem hiding this comment.
I think we can remove UnityEngine and DCL.ECSRuntime 👌
| var audioSourceComponentList = audioSourceComponent.GetForAll(); | ||
|
|
||
| // Loop through every audio source component | ||
| foreach (var component in audioSourceComponentList) |
There was a problem hiding this comment.
I think it might be worth it to switch from a foreach to a for loop to reduce allocations. What do you think?
There was a problem hiding this comment.
@AlejandroAlvarezMelucciDCL you are right! The IEnumerator call will allocate, good spot
| wrappedComponent.WrappedComponent.Model.AudioClipUrl ??= model.audioClipUrl; | ||
| wrappedComponent.WrappedComponent.Model.CurrentTime = model.audioSource.time; | ||
|
|
||
| if (componentsWriter.TryGetValue(scene.sceneData.sceneNumber, out var writer)) |
There was a problem hiding this comment.
Maybe we can re-order this check to the beginning to avoid doing all the above in case the componentsWriter doesn't have a writer for the given sceneNumber?
There was a problem hiding this comment.
Uhmmm it would be weird to have a scene without a components writer, to be honest
What does this PR change?
Introduces AudioSourceSystem that can write back the state of an audio source.
Our Code Review Standards
https://github.com/decentraland/unity-renderer/blob/master/docs/code-review-standards.md
Copilot summary
copilot:summary