Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class RayScript : MonoBehaviour
- {
- Ray ray;
- RaycastHit hit;
- public GameObject panel;
- int pagesNum;
- void Start()
- {
- pagesNum = 0;
- }
- void Update()
- {
- var ray = Camera.main.ViewportPointToRay(new Vector3(0.5F, 0.5F, 0));
- RaycastHit hit;
- if (Physics.Raycast(ray, out hit))
- {
- Debug.Log(hit.collider.gameObject.name);
- if (hit.collider.gameObject.tag == "Paper" && hit.distance <= 1.3)
- {
- panel.SetActive(true);
- if (Input.GetKeyDown(KeyCode.E))
- {
- pagesNum += 1;
- Destroy(hit.collider.gameObject);
- }
- } else
- {
- panel.SetActive(false);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement