Open Vytek opened 7 years ago
Copied from: https://steamcommunity.com/app/358720/discussions/0/341537671986065508/
Removing all garbage generation from the SteamVR Unity SDK plugin
Hey everyone,
The Unity plugin missed a few spots where garbage was generated. I managed to fix all the issues and posted them over at the Unity forums. Hopefully the next version generate zero garbage while it does its thing.
Link to the discussion[forum.unity3d.com]
Takeaways include.
Disable "Update Dynamically" on all SteamVR_RenderModel scripts. This will disable button clicks and trigger moves. SteamVR's use of params object[] args generates a new array and thus new garbage. Check the link for more info on the fix. The render loop (which is generated every frame) creates a new WaitForEndOfFrame() object. Instead create a single class at the start and reference that. Check the link for all the details.
The Update Dynamically causes a lot of garbage because it uses a foreach loop on the enumerator. Couldn't figure out how to make that into a for loop. Foreach loops generate garbage in Unity's version of Mono.
Hope that the Unity devs at Valve can fix this for the next release! Took a while to track down these garbage issues but now I am happy to report I get zero generate garbage while running my scene. Weee!
Hey, original poster over at the Unity forums. Happy to answer any questions about my implementation to remove all the garbage. I think snippets of all the code are on the Unity answer forum page.
Happy to post again here if needed.
Many developer have problem with FPS using SteamVR Plugin for Unity (this problem is now only for HTC controller, etc..) Please see:
https://forum.unity3d.com/threads/steamvr-htc-vive-weird-fps-issue.426904/