- Home /
.enabled with Android
Does .enabled not work on Android? I'm trying something very simple and it works fine while testing it in Unity but when I try to push it to my phone for testing I get the error: 'enabled' is not a member of 'UnityEngine.Component'.
function OnTriggerEnter(other: Collider) {
gameObject.GetComponent("Testscript").enabled = true;
}
You cannot use dynamic typing on any mobile unity platform.
Answer by TomHunt · Oct 15, 2010 at 02:04 PM
Try this to get around the dynamic typing limitation:
var script : TestScript = gameObject.GetComponent(TestScript); script.enabled = false;
i'll just quickly add that i've verified that this does work. you just have to make sure you assign the result of GetComponent to a typed var; then you can .enable = true or false to your hearts content :)
Your answer
Follow this Question
Related Questions
renderer.enabled working on PC but not android? 1 Answer
Canvas no longer appearing in Android build 1 Answer
Application.OpenURL not working 1 Answer
xmlDocument.loadXml/load raises NotImplementedException on android, works in editor 1 Answer
Unity HTTP Post WebRquest not working on some Android Devices 0 Answers