I’m using the following loop to grab files for an animation. This method makes it really easy for our artists to export animations from flash as PNG sequences. It works perfectly fine when run from within the unity editor. The files load and the animations play at the right time; however, when we build the project for the Web Player (this game will only be playable through a browser) the animations don’t happen and I’m sure it’s because of the LoadAssetAtPath function.
Any Ideas?
while (true)
{
string tempPath = PATH + mName + intToPaddedString(currentFrame, 4) + ".png";
tempTexture = null;
tempTexture = Resources.LoadAssetAtPath(tempPath, typeof(Texture2D));
if (tempTexture == null)
return;
mTextures.Add(tempTexture as Texture2D);
currentFrame++;
}
You should use Resources.Load (or Resources.LoadAll) to load assets at runtime. Make sure that your resorces are located under Assets/Resources (subdirectories are supported).
LoadAssetFromPath is meant to be used for your own editor extensions only. Citing from script reference for LoadAssetAtPath:
This function always return null in the standalone player or web player. This is useful for quickly accessing an asset for use in the editor only.