Skip to content

Instantly share code, notes, and snippets.

@TheStoneBook
Last active July 1, 2018 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheStoneBook/54e5248c17f8b62f5054ebba6d5a1e11 to your computer and use it in GitHub Desktop.
Save TheStoneBook/54e5248c17f8b62f5054ebba6d5a1e11 to your computer and use it in GitHub Desktop.
【Unity】ドラッグでオブジェクトを動かす【EventSystem】
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
//CameraのProjectionはOrthographicに。
public class DragEventTest : MonoBehaviour,IDragHandler {
public void OnDrag(PointerEventData data){
Vector3 TargetPos = Camera.main.ScreenToWorldPoint (data.position);
TargetPos.z = 0;
transform.position = TargetPos;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment