Last active
July 1, 2018 16:54
-
-
Save TheStoneBook/54e5248c17f8b62f5054ebba6d5a1e11 to your computer and use it in GitHub Desktop.
【Unity】ドラッグでオブジェクトを動かす【EventSystem】
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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