I was fully convinced this would not work GetComponent(“test”).enabled = true; actually it does
if you drag both scripts onto same object, Nobody bothered to explain that, Maybe it is that self explanatory? Anyway i feel a little stupid but Heh i learned something new.
junktest.js
function OnMouseDown() {
if (Input.GetButtonDown("Fire1")){
Debug.Log("Fired");
GetComponent("test").enabled = true;
}
}
function OnMouseUp() {
Debug.Log("Mouse Up");
GetComponent("test").enabled = false;
}
You can absolutely do that, the only problem with your code is the extra bracket dangling. However, that will disable the script if you click anywhere, not over the gameobject. Trying moving your code into OnMouseDown():