-
Notifications
You must be signed in to change notification settings - Fork 238
Fix lipsync not starting when renderer changes #9905
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
base: master
Are you sure you want to change the base?
Conversation
|
badandbest pointed out in the Discord that the public keyword was required because of TypeLibrary restrictions. I'm keeping it public to match Dresser's implementation for now, but if you'd like I can change it to be private with [Expose] instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request fixes an issue where lip sync does not start when the Renderer property is set on a Voice component after initialization. The fix adds a Change attribute to the Renderer property that triggers initialization logic when the renderer is updated at runtime.
Changes:
- Added a
Changeattribute to theRendererproperty to trigger a callback when the renderer is changed - Implemented the
OnRendererChangepublic method to handle renderer changes by initializing the morphs array and enabling/disabling lip sync appropriately
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
One thing I forgot to mention: Perhaps the same code should also run when LipSync is changed between true and false? If you'd like, I'll add another Change method which would do the same thing. |
|
Why [Change] over a standard C# property setter? |
This is just my opinion, but I believe setters should be used for verification of inputs while side effects as a result of the value changing should be elsewhere. I really like the Change attribute because it fills that gap. If you're saying that a setter would be following existing conventions, I could do that instead. |
|
Also in favor of using a regular setter. |
|
Understood. I'm gonna look into that possible NRE as well. |
|
I went ahead and fixed the possible NRE in the constructor as well since that's where I took that piece of code from. |
Summary
This pull request adds a Change attribute to the Renderer property on the Voice transmitter component.
The executed method will enable lipsync if the Renderer is valid.
Motivation & Context
Fixes: #201
Implementation Details
I had to make the Change method public, or it wouldn't be found:



This matches the usage in Dresser:
sbox-public/engine/Sandbox.Engine/Scene/Components/Game/Dresser.cs
Line 284 in 91fa40b
The contents of the Change method are taken from the OnInternalEnabled function:
sbox-public/engine/Sandbox.Engine/Scene/Components/Audio/VoiceComponent.cs
Lines 155 to 158 in 91fa40b
With just that code, the lip sync would only work when you stopped talking and then started talking again, so I looked at this as well:
sbox-public/engine/Sandbox.Engine/Scene/Components/Audio/VoiceComponent.cs
Lines 402 to 426 in 91fa40b
(emphasis on line 417)
The current code seems to work in both instances. Feel free to test it with the sample project in the linked issue.
Checklist