createAsset is super slow

Hello,
I got a new kind of problem.
Figured out that using createAsset() is slow and asynch. Is there a way to make sure assets has been create before moving on in the iteration?
regards! Tom

I assume you are talking about this one:

Why do you believe it is async? Sometimes it is necessary to refresh the asset database:

Though that shouldn’t be the case for CreateAsset as far as I know.

Even if it’s slow, why would you care since it’s only used in the editor? It’s not like it’s killing your framerate.

@Dantus ; i believe it is asynch, because, my loop is already finished creating 4000 chunks, but I can see them being written to disk. They come one by one. And I don’t know what really happens on CreateAsset, but the data is already imported into Unity. At the end I don’t have to wait for importing assets. The next iteration is not waiting for having the asset on the disk stored.

@LightStriker_1 : because Unity freezes a lot and I need to force quit the application to start over. (resume where it left)

If everything works in a reliable way, it doesn’t matter whether an async operation takes place. As there seems to be an issue, you should definitely submit a bug report.

[USER=11073]

Wait… You’re creating 4,000 files? There is no way for you to condense the data into lesser number of files?[/user]

@Dantus : i see, or perhaps wait for Unity 5 with the 64bit editor…

@LightStriker_1 : yes, 4000+, I am filling up a huge terrain with a lot of rocks and stuff. I am limited to 65000k vertices so, this terrain is being split up in chunks each filled with rocks etc. 4000 chunks so far. I have managed to create more effective code where Unity freezes much less now. Currently, Unity does give up around 1000 a 1200 assets created. Stil freezing however. These data is loaded based upon current camera location. Works great. It is start looking like a landscape instead of a textured terrain. But it is indeed much a painful proces, because Unity doesn’t seem to handle large amount of data very well. Less number of files means less detail. :wink:

Hey, I found a solution to this

I had +3000 objects to save, and I realized ‘AssetDatabase.CreateAsset’ is Pretty Slow, so I did like this.

    AssetDatabase.StartAssetEditing();
    foreach(.....)
             AssetDatabase.CreateAsset(....)
    AssetDatabase.StopAssetEditing();

That actually saved me!

9 Likes

You saved me!