Text based asset, fileID, guid

I have two projects, one uses a plugin with source code, the other uses the DLL version of the same plugin.
The plugin creates custom assets files with tons of ScriptableObjects in them. In both projects assets are
forced to be text based.

I’m trying to move assets between these projects but the trouble is that off the bat they don’t load at all.
I compared newly created assets files from both projects and saw these kind of differences:

Writing a parser which replaces one value with another would be simple, but there are about 40 classes
involved so manually gathering the replacement pairs is something I’d like to avoid. Is there a way to get
fileID and guid values from code?

Not sure how or what a file id is used for, but to get a guid:

Given an object someObject:

string assetPath = AssetDatabase.GetAssetPath(someObject);
string guid = AssetDatabase.AssetPathToGUID(assetPath);

Unfortunately it gets the guid for the asset and not the guid for an object inside the
asset.

Note that only files have GUID’s – all the assets in a particular asset file (for example all the ScriptableObject classes in a DLL) will have the same GUID.

For a loose script, the fileID is always 11500000, which is the class ID for MonoScript multiplied by 100,000.

For classes in a DLL, the fileID seems to be related to the namespace and class name of the type, but I wish I knew the relationship – it’s certainly not the C# GetHashCode() of the type name, nor is it the instance ID of the MonoScript asset. (I briefly thought that in the DLL case too the fileID is also a multiple of the MonoScript class ID, 115, but then realized Windows Calculator in Programmer view doesn’t show any decimal places, whoops!)

2 Likes

Not sure to follow… But if you create asset in two project, even if they are created the same way, they will never have the same Guid.

Bit of a necropost, but I found the answer to this and posted here: YAML fileID hash function for DLL scripts - Unity Engine - Unity Discussions

1 Like

Wow, good job, thanks!

Very old post, but I searched a solution to the changes in Scriptable Object’s guid embedded in DLLs, and after a long time I found the reason of these guid changes.

The m_Script: {fileID: 936005545, guid: b4c82f59e61bef74e92f25aa89b92e99, type: 3} is the reference to the class of the ScriptableObject.
If your asset has the guid:XXX referenced in m_Script, is because the main class “CusomAsset.cs” have the guid XXX in its .meta file.Some changes in these .meta files can change the guid, and this will change the m_Script{guid} of the Scriptable Object’s instances.

If you have the source code of the plugin, you probably can change the guid of the .meta file, and make it compatible with the DLL guid.

Source: Unity script .meta files - Ninjacrab