Fog*_*zie 2 c# animation textures unity-game-engine web
我正在使用以下循环来抓取动画文件.这种方法使我们的艺术家很容易从Flash中导出动画作为PNG序列.从统一编辑器中运行时,它工作得很好.文件加载和动画在合适的时间播放; 但是,当我们为Web Player构建项目时(此游戏只能通过浏览器播放)动画不会发生,我确定这是因为LoadAssetAtPath函数.
有任何想法吗?
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++;
}
Run Code Online (Sandbox Code Playgroud)
您应该使用Resources.Load(或Resources.LoadAll)在运行时加载资源.确保您的资源位于资产/资源(支持子目录)下.
LoadAssetFromPath仅用于您自己的编辑器扩展.引用LoadAssetAtPath的脚本引用:
此函数始终在独立播放器或Web播放器中返回null.这对于快速访问资产以仅在编辑器中使用非常有用.