SwitchCamera.cs 634 B

1234567891011121314151617181920212223242526
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class SwitchCamera : MonoBehaviour
  5. {
  6. // Start is called before the first frame update
  7. void Start()
  8. {
  9. }
  10. // Update is called once per frame
  11. void Update()
  12. {
  13. if (Input.GetMouseButton(0))
  14. {
  15. Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); //camare2D.ScreenPointToRay (Input.mousePosition);
  16. RaycastHit hit;
  17. if (Physics.Raycast(ray, out hit))
  18. {
  19. print("hit:" + hit.collider.gameObject.name);
  20. }
  21. }
  22. }
  23. }