- Home /
Custom editor super slow even with no draw operations
I have a big class (object has large arrays serialized), and default inspector is totally unusable, super slow and unresponsive. I've done a custom inspector to work on this object with responsiveness, and it worked fine. But now, object has even larger arrays, and custom inspector is getting also super slow. I've tried with just this OnInspectorGUI:
public override void OnInspectorGUI()
{
GUILayout.Space(1000);
GUILayout.Label("______________");
}
and it's still suuuper slow on scrolling. Deep profile says the culprit is
serializedobject.Update()
, which is executing in background while the object is selected, even when it's not necessary. So, is there any way to optimize this custom inspector by saying it not to update unless necessary? I don't want serializedobject.Update() to be executing twice per frame and wasting more than half second if I won't be modifying the object.
Thanks for your time!
Answer by Bunny83 · Feb 05, 2019 at 04:30 PM
You just shouldn't put too much serialized data into a single object. That kind of data do we talk about? If it's static / configuration data it probably should be stored in a seperate ScriptableObject. Maybe you can break down the data into smaller chunks.
Your question is lacking this important detail and without knowing how much data and what kind of data you have stored in your object we can't suggest any alternatives.
At runtime if you select an object, Unity has to update the inspector every frame. The inspector always works on the serialized data. So the object need to be serialized once per frame. If you put too much serialized information into a single object, of course it slows down the update of the inspector.
it's data to access and show in runtime, right now it's totally localized in that object. I wouldn't want to split it in different objects for code simplicity, so I'm assu$$anonymous$$g this is inevitable then?
Your answer
Follow this Question
Related Questions
How can i get SerializedProperty from UnityEvent which in List. Sorry for my Eng. 2 Answers
Questions Regarding Images in Custom Inspector/Editor 1 Answer
How to Hide/Show List or Array in the inspector based on a variable? 0 Answers
How do I access the "Edit Collider" function from the inspector in a custom editor. 1 Answer
How to allocate layout region inside the inspector? 1 Answer