Could not extract GUID in text file *.anim when loading sprites from AssetBundles
Unity v2018.2.15f1
Hi,
I have a json file detailing the animations to be imported into my scene at runtime. It looks like the following:
{
"items": [
{
"name": "anim1",
"animations": [
{
"name": "anim1_in"
},
{
"name": "anim1_out"
}
],
"otherParams": [ ... ]
},
...
]
}
In a script called AnimationImporter.cs
. I'm reading from this json file in order to roughly do the following (for each anim
in animations
, in each item
in items
):
Create an animation controller
Load sprites
Setup animation params (AnimationClip and AnimationEvents)
Build animation asset
During step 2, I can successfully load the sprites from my resources folder like so:
Sprite[] sprites = Resources.LoadAll<Sprite>("Animation Assets/" + item.name + "/" + anim.name);
But I need to load from AssetBundles instead, so I've bundled all my assets in a directory tree identical to the json file. I try to load them like this:
bundleRequest = AssetBundle.LoadFromFile(animBundlePath.ToString());
if (bundleRequest == null) {
Debug.LogError("Failed to load AssetBundle!");
return;
}
Sprite[] sprites = bundleRequest.LoadAllAssets<Sprite>();
Which results in numerous of the following error:
Could not extract GUID in text file Assets/Resources/Animation Controllers/anim1/anim1_in.anim at line 390.
UnityEditor.AssetDatabase:CreateAsset(Object, String)
AnimationImporter:.cctor() (at Assets/Editor/Scripts/AnimationImporter.cs:182)
UnityEditor.EditorAssemblies:ProcessInitializeOnLoadAttributes()
At Assets/Editor/Scripts/AnimationImporter.cs:182
is the following line (part of step 4):
AssetDatabase.CreateAsset(clip, "Assets/Resources/Animation Controllers/" + item.name + "/" + clip.name + ".anim");
Almost every .anim file in my build gets this error. If I open one of them with a text editor I can see that each GUID line looks something like this:
value: {fileID: -876891797413774589, guid: 00000000000000000000000000000000,
type: 0}
...where fileID
is a negative int and guid
is 0.
The assets successfully load into my scene in editor, but I can't create a standalone build while the error persists.
This seems to be a problem with serialization. I'm new to AssetBundles and don't know too much about how Unity serializes things, and the documentation hasn't been much help thus far. Is this a bug? Any tips on how to move forward resolving this issue would be greatly appreciated!
Your answer
Follow this Question
Related Questions
Resolve AnimationClip curve binding at runtime. 0 Answers
animator.crossfade() not working properly 2 Answers
Rigging af 2D character, so the feet is the root 0 Answers
my animation glitches when i add more keyframes 0 Answers
Does changing multiple sprites on a single animation affect performance? 0 Answers