You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.3 KiB
55 lines
1.3 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.EventSystems;
|
|
public class RayPlayer : MonoBehaviour
|
|
{
|
|
public RaycastHit Hit;
|
|
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
Ray();
|
|
/* if (Input.GetKeyDown(KeyCode.K))
|
|
{
|
|
SceneManager.LoadScene(1);
|
|
GameManager.Instance.a++;
|
|
|
|
}*/
|
|
}
|
|
public void Ray()
|
|
{
|
|
Hit = chuanjianshexian();
|
|
if (Hit.collider != null)
|
|
{
|
|
|
|
if (Hit.collider.tag == "Tool" && Input.GetMouseButtonDown(0))
|
|
{
|
|
Debug.Log(Hit.collider.name);
|
|
TipsUI.Instance.OpenUI(Hit.collider.gameObject);
|
|
}
|
|
|
|
|
|
if(Hit.collider.tag=="Floor" && Input.GetMouseButtonDown(0)&&!EventSystem.current.IsPointerOverGameObject())
|
|
{
|
|
Hit.collider.gameObject.GetComponent<MaterialButton>().shiyong();
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
public RaycastHit chuanjianshexian()
|
|
{
|
|
RaycastHit hit;
|
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
|
Physics.Raycast(ray, out hit);
|
|
return hit;
|
|
}
|
|
}
|