当我在Unity中将平台切换到Android时,为什么会出现NullReferenceException?

时间:2018-01-30 06:00:07

标签: android unity5 nullreferenceexception virtual-reality build-settings

我做的步骤:

Assets>Import package>Environment

Assets>Import package>custom package>GoogleVRForUnity_1.120.0.unitypackage

GameObject> 3D object> Terrain

Save Scene

Build Settings> add open scene

Build Settings> Switch platform - Android

错误详情:

 NullReferenceException
 UnityStandardAssets.CrossPlatformInput.MobileControlRig.EnableControlRig
 (Boolean enabled) (at Assets/Standard
 Assets/CrossPlatformInput/Scripts/MobileControlRig.cs:89)
 UnityStandardAssets.CrossPlatformInput.MobileControlRig.CheckEnableControlRig
 () (at Assets/Standard
 Assets/CrossPlatformInput/Scripts/MobileControlRig.cs:80)
 UnityStandardAssets.CrossPlatformInput.MobileControlRig.OnActiveBuildTargetChanged
 (BuildTarget previousTarget, BuildTarget newTarget) (at
 Assets/Standard
 Assets/CrossPlatformInput/Scripts/MobileControlRig.cs:98)
 UnityEditor.Build.BuildPipelineInterfaces.OnActiveBuildTargetChanged
 (BuildTarget previousPlatform, BuildTarget newPlatform) (at
 C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:345)
 UnityEditor.Build.BuildPipelineInterfaces:OnActiveBuildTargetChanged(BuildTarget,
 BuildTarget)

请帮忙。我一直坚持下去。

Unity 2017.3.0f3

1 个答案:

答案 0 :(得分:1)

对于使用 UnityStandardAssets、为 Android 构建并正在制作 2D 应用程序/游戏的人,我有一个解决方案: 转到构建设置并单击播放器设置。然后展开“其他设置”。向下滚动后,您会找到一个名为“脚本定义符号”的文本框。不带“”符号输入:“CROSS_PLATFORM_INPUT;MOBILE_INPUT”。我使用的是 Unity 2020.3.1f1 个人版。