Quantcast
Channel: Answers for "gameObject.GetComponent("Script").enabled = true not working"
Browsing all 10 articles
Browse latest View live

Answer by Hybris

I think it has to be: `gameObject.GetComponent(Script).enabled` If that doesn't work try making a variable out of the GameObject the script is attached to. or try `GetComponent("Script"//or just...

View Article



Answer by Kryptos

Once again. NEVER use the *string-based* version of the method GetComponent which returns a Component (the compiler cannot infer the type). Instead, use the *type-based* method: // JS...

View Article

Answer by Ninita

or you could do `(gameObject.GetComponent( "Script" ) as MonoBehaviour).enabled = true;`

View Article

Answer by frogsbo

works: ` `camera.main.gameObject.GetComponent(MouseOrbit).enabled = true ;

View Article

Answer by Michio Magic

I had to use this > to access the First Person Controller component ... gameObject.GetComponent(UnityStandardAssets.Characters.FirstPerson.FirstPersonController).enabled = false;

View Article


Answer by Hybris

I think it has to be: `gameObject.GetComponent(Script).enabled` If that doesn't work try making a variable out of the GameObject the script is attached to. or try `GetComponent("Script"//or just...

View Article

Answer by Kryptos

Edit -> Unity 5 : GetComponent("ScriptName") is deprecated (the string version). You must use one of the other versions....

View Article

Answer by Ninita

or you could do `(gameObject.GetComponent( "Script" ) as MonoBehaviour).enabled = true;`

View Article


Answer by frogsbo

works: ` `camera.main.gameObject.GetComponent(MouseOrbit).enabled = true ;

View Article


Answer by Michio Magic

I had to use this > to access the First Person Controller component ... gameObject.GetComponent(UnityStandardAssets.Characters.FirstPerson.FirstPersonController).enabled = false;

View Article
Browsing all 10 articles
Browse latest View live




Latest Images