• Unity3D: Исключение NullReferenceException при переключении платформы на Android

    NULLREFERENCEEXCEPTION IN MOBILECONTROLRIG.ENABLECONTROLRIG AFTER SWITCHING PLATFORM IN EDITOR

    Steps to repro:

    1. Open attached project;
    2. Go to BuildSettings (File -> Build Settings);
    3. Select any other available platform (i.e. WebGL);
    4. Click Switch Platform.

    Expected result:
    Platform is switched without errors.

    Actual result:

    Error:

    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:82)
    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)

    Notes:

    - Reproducible in 2017.2.0b3, 2017.1.0f3;
    - The code doesn′t compile in 5.6.1p2;
    - Reproducible on Windows 10;
    - Uncommenting line 82 in ′MobileControlRig.cs′ script fixes the issue.


    Solution:

    Change de namespace to
    namespace Standard_Assets.CrossPlatformInput.Scripts

    if has error about UnityEngine dont found, use
    #if UNITY_EDITOR
    using UnityEditor;
    #endif







Добавить
Загрузка...

Войти на сайт

Регистрация