Performance, Performance, Performance!
Performance optimization is one of the essential tasks for any Virtual Reality developer because any drop in the frame rate can cause motion sickness. It is especially important when we are talking about mobile VR because the speed of smartphones is far lower than gaming personal computers, at least at the moment. There are many ways to optimize the performance of our apps, and I will no doubt share a lot of them here in the future. Today we are focusing on a very simple, but an essential trick. Every object which is not supposed to be moved needs to be marked as MARKDOWN_HASHa81259cef8e959c624df1d456e5d3297MARKDOWN_HASH
. This is achieved by selecting the “Static” checkbox in the properties inspection as demonstrated in the screenshot below.
However, when our project grows in size and we add lots of different models onto the scene, it becomes very difficult to keep the track of all of the objects. And this is where the script written by David becomes very handy, thanks to the ability of Unity extensions.
Filter Non-Static Objects Script.
For your convenience, I have created a Unity package which includes David’s script. It is very simple to use! Download the package, open your Unity project, then double-click the downloaded MARKDOWN_HASHd54e62c371f2b74714cc5009f8f4da26MARKDOWN_HASH
file. Importing the script would add a new menu item to Unity called “Custom”. Now you can select “Custom” -> “Select Non-Static” and all of the objects which are currently not marked as MARKDOWN_HASHa81259cef8e959c624df1d456e5d3297MARKDOWN_HASH
will get highlighted.
Extra
For all of the curious minds, here is the source code of the script which we have just imported.
using UnityEditor; using UnityEngine; using System.Collections.Generic; public class FilterNonStaticObjects : EditorWindow { [MenuItem( "Custom/Select Non-Static" )] static void Init() { Object[] gameObjects = FindObjectsOfType( typeof ( GameObject ) ); GameObject[] gameObjectArray; gameObjectArray = new GameObject[ gameObjects.Length ]; int arrayPointer = 0; foreach ( GameObject gameObject in gameObjects ) { StaticEditorFlags flags = GameObjectUtility.GetStaticEditorFlags( gameObject ); if ( ( flags & StaticEditorFlags.LightmapStatic ) == 0 ) { gameObjectArray[ arrayPointer ] = gameObject; arrayPointer += 1; } } Selection.objects = gameObjectArray; } }
Recent Comments