- Home /
android plugin for script.enabled
I wrote a script with C# and I wanna call the function of it using JavaScript. When I using android platform an error note with BCE0019: 'enabled' is not a member of 'Object'.
I know the I havn't created an android plugin. Could someone tells me a detail steps to use the script enabled function.
Thx in advance.
Script: var script; script = gameObject.GetComponent("CanReplay"); script.enabled = true;
p.s CanReplay is C# script that I want to enalbed.
Answer by aldonaletto · Dec 30, 2011 at 05:00 AM
Unity can't guess what's the script variable type, and assumes the generic object type. You should declare its type like this:
var script: CanReplay = gameObject.GetComponent("CanReplay");
script.enabled = true;
But CS and JS can't see each other because the compilers are independent. If Unity complains that "CanReplay isn't a valid type" or something like this, you can use another trick: declare script as a MonoBehaviour:
var script: MonoBehaviour = gameObject.GetComponent("CanReplay");
script.enabled = true;
To aldonaletto :
It fixed. Thanks a lot! When the C# is in the Standard Asset folder, we can see it using "var script: CanReplay = gameObject.GetComponent("CanReplay");" And also the other one works no matter where the it stored. thanks again. :)
Yes, scripts already compiled in an early phase can be seen by the others compiled in subsequent phases, no matter in what language they were written - but not the other way around, unfortunately.
Answer by SamyTaz · Jul 02, 2017 at 05:58 PM
Hello guys please help me by fix my script .I want to active my car controller script in by writng script in java i use this script on PC Platform its work perfect But when i awitched on Android PlateForm the following error appear "Enabled" is not a member of unity...Please help professional guys....I use this script on Pc Platform
Var Carcontroll : GameObject; function Start () { CarControll.GetComponent("CarScriptName").enabled =true; }
Its work perfect for Pc Platform But For Android Platform "enabled" is not a member of unity error comes
Please Help Me Guys ..Thank You In Advance