Skip to content
Snippets Groups Projects
LaserPointer.cs 574 B
Newer Older
  • Learn to ignore specific revisions
  • MaZiFAU's avatar
    MaZiFAU committed
    using UnityEditor;
    
    MaZiFAU's avatar
    MaZiFAU committed
    public class LaserPointer : Editor
    
    {
        static public RaycastHit laserHit;
        static public bool laserBool;
    
        [ExecuteInEditMode]
        static void Init()
        {
            laserBool = false;
        }
    
        void OnSceneGUI()
        {
            Vector3 mousePosition = Event.current.mousePosition;
            Ray ray = Camera.current.ScreenPointToRay(mousePosition);
            RaycastHit tempHit;
    
            if (!(laserBool = Physics.Raycast(ray, out tempHit, Mathf.Infinity, int.MaxValue)))
    
    MaZiFAU's avatar
    MaZiFAU committed
                return;