简体   繁体   English

Resources.LoadAssetAtPath()在Unity3D WebBuild中不起作用

[英]Resources.LoadAssetAtPath() not working in Unity3D WebBuild

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. 这种方法使我们的艺术家很容易将Flash中的动画导出为PNG序列。 It works perfectly fine when run from within the unity editor. 从unity编辑器中运行时,它工作得很好。 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. 但是,当我们为Web Player构建项目时(该游戏只能通过浏览器进行播放),动画不会发生,并且我相信这是由于LoadAssetAtPath函数引起的。

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. 您应该使用Resources.Load (或Resources.LoadAll )在运行时加载资产。 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. LoadAssetFromPath仅可用于您自己的编辑器扩展。 Citing from script reference for LoadAssetAtPath : 脚本参考中引用LoadAssetAtPath

This function always return null in the standalone player or web player. 在独立播放器或网络播放器中,此函数始终返回null。 This is useful for quickly accessing an asset for use in the editor only. 这对于快速访问仅在编辑器中使用的资产很有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM