Advertisement
Guest User

Untitled

a guest
Aug 24th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. public class RayScript : MonoBehaviour
  7. {
  8.  
  9. Ray ray;
  10. RaycastHit hit;
  11. public GameObject panel;
  12. int pagesNum;
  13.  
  14. void Start()
  15. {
  16. pagesNum = 0;
  17. }
  18.  
  19. void Update()
  20. {
  21. var ray = Camera.main.ViewportPointToRay(new Vector3(0.5F, 0.5F, 0));
  22. RaycastHit hit;
  23.  
  24. if (Physics.Raycast(ray, out hit))
  25. {
  26. Debug.Log(hit.collider.gameObject.name);
  27.  
  28. if (hit.collider.gameObject.tag == "Paper" && hit.distance <= 1.3)
  29. {
  30. panel.SetActive(true);
  31. if (Input.GetKeyDown(KeyCode.E))
  32. {
  33. pagesNum += 1;
  34. Destroy(hit.collider.gameObject);
  35. }
  36. } else
  37. {
  38. panel.SetActive(false);
  39. }
  40.  
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement