Search Issue Tracker

By Design

Votes

1

Found in

2017.2.0b3

Issue ID

930177

Regression

No

NullReferenceException in MobileControlRig.EnableControlRig after switching platform in Editor

Deployment Management

-

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)

is thrown in the console. See attached video.

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.

Comments (12)

  1. mahneovu

    Jan 23, 2024 10:28

    happens in 2019.4.10f1 when switching to Standalone from Android

  2. HapyTheRealOne

    Apr 13, 2021 12:25

    I tried everything that was posted here, but nothing worked.
    I tried changing the namespace, deleting the "using Systems;"

    I tried everything and the error is still there.

  3. Neuroticism-

    May 26, 2020 21:36

    If you downloaded standard assests go into MobileControlRig script and get rid of using system;
    then write this
    #if UNITY_EDITOR
    using UnityEditor;
    #endif
    using UnityEngine;
    should work. It worked for me.

  4. Dusko9

    Apr 24, 2019 01:44

    Same here. 2018.3.0f2
    Don't know how this affects since I'm still able to build the game for Android (and no issues playing it).

  5. 40detectives

    Apr 21, 2019 13:05

    This is still happening

  6. BrianTK

    Apr 01, 2019 14:41

    Também estou com esse erro ao tentar usar prefab MobileSimgle não os botões ficam bloqueado e da esse erro não dá pra ativar os botões

  7. Thorgaer

    Mar 27, 2019 08:42

    This error is still there in 2018.3.6...

  8. TheNenet

    Jan 30, 2019 15:02

    Issue not resolved in 2018.2.20f1

  9. Spikeyo

    Dec 16, 2018 10:10

    Also ran into this problem in 2018.3

  10. Juan_Luis

    Dec 02, 2017 13:31

    Solution:

    Change de namespace to
    namespace Standard_Assets.CrossPlatformInput.Scripts

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

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.