首页 > 解决方案 > 无法在 Unity 中构建 WebGL

问题描述

我正在尝试在 WebGL 中构建我的统一项目,但它一直给我一个错误。构建结果说它成功但在文件夹中,什么都没有。

这是我得到的错误。

FileNotFoundException:找不到文件“C:\Users\TIGER\Desktop\UnityTest\Prototype3\Temp\StagingArea\Data\Native\build.bc”System.IO.FileStream..ctor(System.String 路径,System.IO. FileMode 模式,System.IO.FileAccess 访问,System.IO.FileShare 共享,System.Int32 bufferSize,System.Boolean 匿名,System.IO.FileOptions 选项)(在:0) System.IO.FileStream..ctor(System. String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) (at :0) (wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string, System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare) System.IO.File.OpenRead (System.String path) (at :0) System.IO.File.ReadAllBytes (System.String path) (在:0) UnityEditor.WebGL.WebGlBuildPostprocessor.LinkBuild (UnityEditor.Modules.BuildPostProcessArgs 参数)(在 /Users/builduser/buildslave/unity/build/PlatformDependent/WebGL/Extensions/Unity.WebGL.extensions/BuildPostprocessor.cs:464)UnityEditor.WebGL.WebGlBuildPostprocessor.PostProcess(UnityEditor.Modules.BuildPostProcessArgs 参数)(在/Users/builduser/buildslave/unity/build/PlatformDependent/WebGL/Extensions/Unity.WebGL.extensions/BuildPostprocessor.cs:954)UnityEditor.Modules.DefaultBuildPostprocessor.PostProcess(UnityEditor.Modules.BuildPostProcessArgs args,UnityEditor.BuildProperties& outProperties) (在 C:/buildslave/unity/build/Editor/Mono/Modules/DefaultBuildPostprocessor.cs:27) UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.String installPath, System.String companyName, System .String 产品名称,系统。Int32 宽度、System.Int32 高度、UnityEditor.BuildOptions 选项、UnityEditor.RuntimeClassRegistry usedClassRegistry、UnityEditor.Build.Reporting.BuildReport 报告)(在 C:/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:286) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr) (在 C:/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)

标签: unity3dunity-webgl

解决方案


使用 unity webgl 时无法访问本地文件系统。如果有任何处理 System.IO 功能的 csharp 文件,请将它们置于此检查并构建。

    #If !UNITY_WEBGL
    #endif

推荐阅读