- Home /
Cannot activate GameObjects in Inspector because of a script?
A few months ago I set up the "Mobile Single Stick Control" from the Standart Assets. I got it fully worked out. Today I updated the Android SDK. Since then, all the children of the Canvas that my joystick is child of are disabled and cannot be enabled (by ticking the checkbox in the Inspector). I have narrowed it down to the MobileControlRig.cs-Script – attached to the Joystick by default – that I have attached to the canvas.
If I disable the script (or attach it to the Joystick), I can activate all the UI GameObjects but the Joystick doesn't move the character. If I have the script enabled, all my UI is disabled including my Joystick. I am sure this only happened because of the SDK update since I have another computer with the exact same setup (exept for the sdk) and the stick works perfectly fine with the script attached to the canvas.
Now I can't get the Joystick to work. I really need help with this one because I can't really continue working on the project without being able to test it.
Thanks in advance.
Answer by Cynikal · Oct 30, 2016 at 06:50 PM
Per the code of MobileControlRig.cs:
private void CheckEnableControlRig()
{
#if MOBILE_INPUT
EnableControlRig(true);
#else
EnableControlRig(false);
#endif
}
private void EnableControlRig(bool enabled)
{
foreach (Transform t in transform)
{
t.gameObject.SetActive(enabled);
}
}
also from the same script:
// this script enables or disables the child objects of a control rig
// depending on whether the USE_MOBILE_INPUT define is declared.
// This define is set or unset by a menu item that is included with
// the Cross Platform Input package.
So, if you have your canvas as a child, and EnableControlRig is false, then it'll disable it all.
You need to enable Mobile Input Mode. If you have imported the cross platform input, you should see a menu item called "Mobile Input", and you should have it as enabled.
Thank you for your help, you were really close to the solution.
It has been activated (has always been) BUT after deactivating and activating again Unity warned that the Platform has not been set to a mobile platform. After switching back to Android it worked like a charm.
It is just strange why the platform was set to PC/$$anonymous$$ac/Linux since I never changed it... $$anonymous$$ust have been after the update or so.
Answer by wmarker · Jan 28, 2018 at 05:25 AM
On reason may no longer enable GameObject is if you restore / import an entire Mobile-specific project through "Collaborate".
strong text The "new" project's build settings return to the default of Standalone. Since Standalone does not have mobile inputs, they are disabled, with an open / non-tickable checkbox in the Inspector.
Answer by sdanialnasir1 · Jul 03, 2018 at 08:59 AM
Hello friend . i am facing the same issue please guide me to solve that
$$anonymous$$obile joystic can't be enabled unless you switch the platform in build settings.So switch the platform before activate mobile joystic in build settings.
Solution is simple. you have to switch to Android or iOS platform from Build Setting .
Problem is you are trying to access the joystick on non mobile platform.
Your answer
![](https://koobas.hobune.stream/wayback/20220612094253im_/https://answers.unity.com/themes/thub/images/avi.jpg)