Most of these involve searching your entire scene graph for some matching list of GameObjects. Example CodeĬertain Unity APIs, although useful, can be expensive to execute. (Bad) Component GetComponent(string)> Avoid expensive operationsĪlthough LINQ can be clean and easy to read and write, it generally requires more computation and memory than if you wrote the algorithm manually. Searching by string in your scene is significantly more costly than searching by Type. It is important to always use the Type-based implementations and never the string-based searching overload. When using GetComponent(), there are a handful of different overloads. Public class ExampleClass : MonoBehaviour Camera.main just uses FindGameObjectsWithTag() underneath, which expensively searches your scene graph for a camera object with the "MainCamera" tag. We recommend caching references to all relevant components and GameObjects at initialization because repeating function calls such as GetComponent() and Camera.main are more expensive relative to the memory cost to store a pointer. The content below covers more in-depth performance practices, especially targeted for Unity & C# development. UnityEngine.XR.XRSettings.renderViewportScale = 0.7f The platform will sample the lower resolution output to build a higher resolution image for rendering on displays. The final image presented on-device has a fixed resolution. Unity provides the ability to easily modify the render target resolution of your application at runtime through the XRSettings.renderViewportScale property. In a development build, the same scopes that you see in Unity's Frame Debugger will be shown in PIX as well and can be inspected and profiled in more detail. There are also detailed instructions on how to use and install PIX for HoloLens 2. PIX can be used to profile Unity applications as well. These options will enable an FPS counter and graph, respectively, that will give you immediate feedback in any running application on your device. You can enable Display frame rate counter in headset and Display frame rate graph in headset. The Device Portal System Performance page has a good summary of CPU and GPU performance of the device. These are usually added when enabling expensive rendering features (for example MSAA, HDR or full-screen effects like bloom) which should be avoided. Ideally, no off-screen render targets should be used on HoloLens. Things to look out for are additional rendering targets and blit commands to copy between them as these are very expensive on HoloLens. It will give you a good overview of what the GPU is doing each frame. Unity's Frame Debugger is also a powerful and insightful tool to use. See Unity's GPU Usage Profiler module for more details. To use GPU profiling, you need to disable Graphics Jobs in the Unity Player Settings. This allows the developer to get a quick approximation if their application is CPU or GPU bounded. With the Unity Profiler connected and after adding the GPU profiler (see Add Profiler in top right corner), one can see how much time is being spent on the CPU & GPU respectively in the middle of the profiler. How to effectively diagnose performance problems with the Unity Profiler.How to connect the Unity profiler to UWP applications remotely.We recommend that you remotely profile your application while running on-device for the most accurate and actionable insights. Although you can run the profiler in-editor, these metrics don't represent the true runtime environment so results should be used cautiously. Unity provides the Unity Profiler built-in, which is a great resource to gather valuable performance insights for your particular app. Some of these recommended settings are highlighted below, as well. That article contains content with some of the most important scene configurations for building performant Mixed Reality apps. The most important first step when optimizing performance of mixed reality apps in Unity is to be sure you're using the recommended environment settings for Unity. Download the Quality Fundamentals app Use recommended Unity project settings
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |