Advertisement
Guest User

Untitled

a guest
Oct 4th, 2015
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Ray : MonoBehaviour {
  5.  
  6. // Use this for initialization
  7. void Start () {
  8.  
  9. }
  10.  
  11. // Update is called once per frame
  12. void Update () {
  13. if (Input.GetMouseButtonDown(0))
  14. {
  15. Vector3 mouse = Camera.main.ScreenToWorldPoint(Input.mousePosition);
  16. RaycastHit2D hit = Physics2D.Raycast(mouse, new Vector3(0, 0, 1), 100);
  17.  
  18. // 可視化
  19. Debug.DrawRay(mouse, new Vector3(0, 0, 100), Color.blue, 1);
  20.  
  21. // コンソール
  22. Debug.Log(hit.collider);
  23. }
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement