Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class RaycastTest : MonoBehaviour {
- public int LayerIndex = 8;
- void Update()
- {
- if (Input.GetMouseButton(0) )
- {
- Ray R = Camera.main.ScreenPointToRay (Input.mousePosition);
- foreach (RaycastHit hitinfo in Physics.RaycastAll(R,10000.0f, LayerIndex ) )
- {
- Debug.Log("HIT "+hitinfo.collider.gameObject+" AT LAYER "+LayerIndex);
- }
- }
- if (Input.GetMouseButton(1) )
- {
- Ray R = Camera.main.ScreenPointToRay (Input.mousePosition);
- foreach (RaycastHit hitinfo in Physics.RaycastAll(R,10000.0f ) )
- {
- Debug.Log("HIT "+hitinfo.collider.gameObject+" WITH LAYER"+hitinfo.collider.gameObject.layer);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement