- Home /
Get callback when assets loading or deserialization finished?
I want to do something when Unity startup or everytime scripts recompiled. I tried [InitializeOnLoadMethod] and [DidReloadScripts] attributes, but Resources.FindObjectsOfTypeAll returns a empty array of a ScriptableObject asset type, which I had already created asset in project. So, I want to get callback when assets loading or deserialization finished, make Resources.FindObjectsOfTypeAll work correctly.
Answer by Adam-Mechtley · Nov 01, 2016 at 10:15 AM
What exactly do you need this script to do? Resources.FindObjectsOfTypeAll() won't return things in the project that are not actively loaded. To get them, you should try something like AssetDatabase.FindAssets() to locate them in the project and then AssetDatabase.LoadAssetAtPath() to actually retrieve it.
Thanks, AssetDatabase.LoadAssetAtPath return correct array, but I found deserialization is not happened before InitializeOnLoad$$anonymous$$ethod after recompiling. DidReloadScripts always happened after deserialization, but doesn't trigger when unity startup.