Please Help,
I am trying to enable Script from another GameObject. Then I am getting this error.
#pragma strict
#pragma implicit
#pragma downcast
var targetObj : GameObject;
function Start () {
}
function Update () {
if(Input.GetKey("w"))
targetObj.GetComponent("Script").enabled = false;
}
Here is one way to solve your problem:
(targetObj.GetComponent("Script") as Script).enabled = false;
There may be others. I don’t know Unityscript as well as I know C#.
Thanks for replying, But now I am getting this error:
The name ‘Script’ does not denote a valid type (‘not found’). Did you mean ‘UnityEditor.ScriptCallOptimizationLevel’?