Search code examples
unity-game-engineunityscript

unity | (how) can I disable the Raycaster by script?


I have this component "Physical Raycaster" and I want to disable/enable it through a js script.

Raycaster

Normally I use this code, but I can't figure out the name for the Raycaster?!

#pragma strict

var targetGameobject : GameObject;

function Start () {

targetGameobject.GetComponent(NAME RAYCASTER).enabled = false;

}

Solution

  • Try this:

    targetGameobject.GetComponent<UnityEngine.EventSystems.PhysicsRaycaster>().enabled = false;