unity burst 报错Burst requires the android NDK to be correctly installed

unity在打包安卓工程的时候出现了以下报错:

BuildFailedException: Burst compiler (1.1.2) failed running

stdout:
Burst requires the android NDK to be correctly installed (it can be installed via the unity installer add component) in order to build a standalone player for Android with ARMV7A_NEON32
The environment variable ANDROID_NDK_ROOT is undefined or empty, is the Android NDK correctly installed?

在unity下添加editor脚本可以解决此问题:

#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using System;

public class FixBurstCompiler : IPreprocessBuildWithReport
{
    public int callbackOrder { get { return 0; } }

    public void OnPreprocessBuild(BuildReport report)
    {
#if UNITY_2021_3_2
        var ndkRoot = EditorPrefs.GetString("AndroidNdkRootR16b");

        Environment.SetEnvironmentVariable("ANDROID_NDK_ROOT", ndkRoot);
#endif
    }
}
#endif

你可能感兴趣的:(unity)