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
CPU Performance Improvements #278
Conversation
- Use simpler return statement in WebXRManager & WebXRPackage (very small improvement) - Use .CompareTag instead of stringComparison in ControllerInteraction (no garbage allocation) - Use TryGetComponent in Controller Interaction (no garbage allocation when component is null) - Use SetLocalPositionAndRotation instead of 2 seperate calls. This changes the amount of time a hierarchy needs to be calculated from 2 to 1, improving CPU substantially for big hierarchies. Added in 2021.3.11, but since there is no compilation check except #if UNITY_2021_3_OR_NEWER, people using version .0 to .10 would get compilation errors. This can be changed, as upgrades within LTS are relatively safe and they can be told to upgrade.
|
Awesome! Thanks! |
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.
Looks great, just some indentation changes needed
Packages/webxr-interactions/Runtime/Scripts/ControllerInteraction.cs
Outdated
Show resolved
Hide resolved
Packages/webxr-interactions/Runtime/Scripts/ControllerInteraction.cs
Outdated
Show resolved
Hide resolved
Packages/webxr-interactions/Runtime/Scripts/ControllerInteraction.cs
Outdated
Show resolved
Hide resolved
Packages/webxr-interactions/Runtime/Scripts/ControllerInteraction.cs
Outdated
Show resolved
Hide resolved
Packages/webxr-interactions/Runtime/Scripts/ControllerInteraction.cs
Outdated
Show resolved
Hide resolved
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.
More indentation changes
Packages/webxr-interactions/Runtime/Scripts/ControllerInteraction.cs
Outdated
Show resolved
Hide resolved
|
🎉 |
|
Thanks for making the changes yourself! |
|
It would be possible to use a custom # define at the top of each script with all the version checks, so 2021LTS users also can use the new feature without changing script. This might start to look even more cluttered however. If you think it's a good idea I could add it to a new PR. Info: |
|
The issue is that it's both on 2021.3.11 and up in the 2021.3.x cycle, but then skips 2022.1.x and 2022.2.x cycles. |
|
Oh that's a big oversight of me indeed! |
|
For now 2022.3 is ok. |
No changes were made a change to functionality, only performance improvement.
transform.SetLocalPositionAndRotation is the biggest changeAdded in 2021.3.11, but since there is no compilation check except #if UNITY_2021_3_OR_NEWER, people using version .0 to .10 would get compilation errors.
#if UNITY_2021_3_OR_NEWER can be used since updates within the same LTS version rarely break the project, but for safety not included in the PR yet.