*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`):
1. Create an animation controller
2. Load sprites
3. Setup animation params (AnimationClip and AnimationEvents)
4. Build animation asset
During step 2, I can successfully load the sprites from my resources folder like so:
Sprite[] sprites = Resources.LoadAll("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();
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!
↧