my expectation was that subasset order would be sorted by either:
the order in which you call AddObjectToAsset(...)
identifier supplied in AddObjectToAsset( identifier, obj );
object name (although objects of the same type sort by name within that same type)
but, it doesn’t seem to be any of them? I’m kinda losing my mind here lol, Is there a way to control this order somehow, ideally from within the ScriptedImporter?
I‘m not aware of any way of sorting subassets for serialization.
Just a thought. I would open the serialized asset in a text editor and move the yaml block of one subasset up or down to see if that affects the order. You may have to LoadAsset the asset explicitly to reload the serialized version, If it doesn‘t it‘s likely internally using an unsorted collection.
In that case you can only load all of the subassets and provide a sorted list in your api. You could also create another subasset (SO) which merely contains that sorted list of subassets (update every time you add/remove a subasset). Might make loading faster.
In my case it’s for a ScriptedImporter, so the serialized data lives in /Library in binary, so I can’t really manually reorder them in there as far as I can tell
Which ordering are you thinking about here? The visual order in the project folder? The order in the yaml file? The order in which things are returned by AssetDatabase.LoadAllAssetsAtPath?
I’m looking at an .fbx file here with a bunch of meshes and animations, and here’s the sub-assets:
So it’s animation, prefab, mesh, animation. All of them seems to be completely alphabetic. It might be that the ModelImporter does different things than the ScriptedImporter, though?