Search Issue Tracker

By Design



Found in


Issue ID




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:


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.

- 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 (11)

  1. 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.

  2. Neuroticism-

    May 26, 2020 21:36

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

  3. 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).

  4. 40detectives

    Apr 21, 2019 13:05

    This is still happening

  5. 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

  6. Thorgaer

    Mar 27, 2019 08:42

    This error is still there in 2018.3.6...

  7. TheNenet

    Jan 30, 2019 15:02

    Issue not resolved in 2018.2.20f1

  8. Spikeyo

    Dec 16, 2018 10:10

    Also ran into this problem in 2018.3

  9. Juan_Luis

    Dec 02, 2017 13:31


    Change de namespace to
    namespace Standard_Assets.CrossPlatformInput.Scripts

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

  10. pRob3

    Oct 13, 2017 12:01

    Also got this bugg when trying to build for OSX on my PC.

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.