0
안녕하세요, 마우스 왼쪽 클릭으로 화면 주위를 움직이는 스프라이트가 있습니다. 문제는 스프라이트를 장면 밖으로 드래그 할 수 있다는 것입니다. 나는 mathf와 클램프의 사용은 믿지만이 스크립트에 그것을 삽입하는 방법을 생각할 수 없다.화면 주위에 스프라이트를 드래그 할 때 마우스 위치를 고정하는 방법을 찾았습니다.
은 기본 mathf.clamp 스크립트를 스프라이트에 삽입하려고 시도했지만 결과는 스프라이트가 클램프의 맨 위와 맨 아래에서 빠르게 빠르게 깜박 거리는 결과를 가져 왔습니다.
using System.Collections;
using System.Collections.Generic; UnityEngine을 사용하는 ;
공용 클래스 DragMove : MonoBehaviour {
public GameObject gameObjectToDrag; // refer to Go that being dragged
public Vector3 Gocenter; // gameobject centre
public Vector3 touchPosition; // touch or click position
public Vector3 offSet; // vector between touchpoint/mouse click to the object centre
public Vector3 newGOCenter; // new center of object
RaycastHit hit; // store hit object information
public bool draggingmode = false; //
// Use this for initialization
void Start() {
}
// Update is called once per frame
void Update()
{
//********************************
// **Click to Drag****************
//********************************
UNITY_EDITOR
만약 내가 코드의이 비트를 사용