Hey guys, just a quick one, ive got a script which holds a large array of a custom class, how ever when the array is filled it lags the editor something rotten, so i thought it might it the inspector having trouble loading the array in the inspector so i added the HideInspector, hower it still no use, as soon as i click the object that has the script with the arry in it then HELLO LAG CITY!!!
however, click on any other other object and its all fine
Just for those who havent read above…
Am using HideInInspector…
EDIT - Am not using gizmos or GUI object in the script so its not that
Even though this question is really old it is still a relevant issue and since I wasn’t able to find any solid answer other than this somehow related issue which was marked resolved but did not solve the problem I’m writing here my observations and workaround.
It seems that the issue is connected either to serialization of such big arrays or it’s drawing in the inspector.
Serialization can be a problem because the OnBeforeSerialize callback can be called repeatedly on an object that has it’s inspector shown and for serializing huge arrays this sure can take a while. This would explain why [HideInInspector] does not help since the array is still serialized.
The other problem related to drawing the inspector is connected to how the array is represented. It’s drawn with some implementation of a TreeView class which can get pretty laggy if not implemented with placeholders instead of collapsed nodes. This second option is less likely since I believe that the default array view should expected larger data sets and also shouldn’t be a problem when the array is not actually rendering.
Only reliable workaround I was able to find was to serialize the array on a different game object, that you can then reference from the main game object. You can also create this storage object on awake of the main object, get a reference to it and completely hide it from hierarchy.