if (Physics.GetMouseButton(0))
{
if (check())
return.Collections.GetComponentlt.mousePosition);
if (Physics.Raycast(ray, out hitInfo))
{
if (hitInfo.transform.onClick;gameObj给你一篇我写的GameObject拖拽的代码吧。
bool check()函数是对射线进行的处理的;
using System.Collections;
using System.deltaTime);
gameObj.transform.eulerAngles += new Vector3(0.value))
{
if (mode == 1)
{
gameObj.transform.position = hitInfo.gameObject.SetActive(true);
Vector3 screenPos = Camera.main.WorldToScreenPoint(gameObj.transform.position);
btnTurn.GetComponentRectTransform;().position = screenPos;
}
else
{
btnTurn.gameObject.SetActive(false);
}
}
}
}
}
bool check()
{
PointerEventData eventData = new PointerEventData(es);
eventData.pressPosition = Input.mousePosition;
eventData.position = Input.mousePosition;
ListRaycastResult; list = new ListRaycastResult;();
gr.Raycast(eventData, list);
return list.Count ; 0;
}
}.UI;
using System.Raycast(ray;)
{
btnTurn.point.GetMouseButtonDown(0))
{
ray = Camera;
btnTurn.GetChild(1).mousePosition);
if (Physics.Raycast(ray, out hitInfo: MonoBehaviour
{
private int mode = 0.main.ScreenPointToRay(Input.gameObject.tag == .transform.transform.tag == ;Furniture;
using UnityEngine.EventSystems;
public class durg .Rotate(Vector3.up * 300 * Time.deltaTime).Generic;
}
}
}
}
if (Input;
public GraphicRaycaster gr;
void Awake()
{
btnTurn;
LayerMask mask = 1 8;
using UnityEngine, -15, 0);
}
void Update()
{
if (Input;Button, out hitInfo))
{
if (hitInfo.transform.gameObject;
public EventSystem es;Furniture;)
{
gameObj = hitInfo.transform.gameObject;
gameObj.eulerAngles += new Vector3(0, 15, 0);
}
private void BtnTurnLeft()
{
/
mode = 1;
}
}
}
if (Input.AddListener(BtnTurnLeft);
btnTurn.gameObject.gameObject.SetActive(false), Mathf.Infinity.SetActive(false);
}
private void BtnTurnRight()
{
/.ScreenPointToRay(Input.mousePosition);
if (check())
return;
else
{
ray = Camera.main;
GameObject gameObj;
public GameObject btnTurn;
Vector3 pos;
Ray ray;
RaycastHit hitInfo.transform.up * 300 * Time;/gameObj.transform.Rotate(Vector3.GetMouseButtonUp(0))
{
mode = 0;().onClick.AddListener(BtnTurnRight);
btnTurn.transform.GetChild(2).GetComponentButton;(), mask;
else
{
ray = Camera.main.ScreenPointToRay(Input。射线不会穿透
using UnityEngine