Hello
The full situation:
We have big static(non-changeable) mesh assets in the project. They are serialized as YAML text which is terrible in a lot of ways:
- git considers these files as text(while they are obviously binary files) which is slow
- cannot use GitLFS because
.asset
extension is used for any scriptableobject - inevitable cost of YAML serialization for both speed and memory efficiency
I’ve looked online and found this brilliant solution:
All works great, but I want to convert existing mesh assets into new compressed assets (which are 10 times smaller) and don’t lose references of original meshes in the scene.
I’m successfully replacing asset guid in the .meta file but the thing is that I also need the fileID.
Here is how reference to original mesh looks in the scene YAML:
m_Mesh: {fileID: 4300000, guid: 57ea71a33f9a3d44eb6c4a2331ed3575, type: 3}
And that’s how it looks for compressed version:
m_Mesh: {fileID: -3755217185360081728, guid: 57ea71a33f9a3d44eb6c4a2331ed3575, type: 3}
As you can see guids are identical, the only difference is fileID. The value 4300000 is hardcoded, it’s a common value for all “standalone” mesh assets.
Original asset meta file:
fileFormatVersion: 2
guid: 57ea71a33f9a3d44eb6c4a2331ed3575
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 4300000
userData:
assetBundleName:
assetBundleVariant:
ScriptedImporter asset meta file:
fileFormatVersion: 2
guid: 57ea71a33f9a3d44eb6c4a2331ed3575
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: e61c173955c747f1836b5b352678d0f5, type: 3}
The fileID: -3755217185360081728
comes from the identifier provided in ScriptedImporter:
ctx.AddObjectToAsset("$IDENTIFIER$", object)
Changing the IDENTIFIER changes fileID.
That means we are “completely” responsible for the fileID value but… we cannot set it directly.
Is there a way to provide a specific fileID? Or how else can I overcome this problem?
Cheers!