BallGenerator.cs 560 B

1234567891011121314151617181920212223242526
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class BallGenerator : MonoBehaviour
  5. {
  6. public GameObject ball;
  7. private void Start()
  8. {
  9. }
  10. private void Update()
  11. {
  12. if (Input.GetMouseButtonDown(0))
  13. {
  14. Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  15. Debug.Log(LayerMask.NameToLayer("Ball"));
  16. if (Physics.Raycast(ray, out var hit, 10f))
  17. {
  18. Debug.Log(hit.transform.name);
  19. }
  20. }
  21. }
  22. }