这个例子是有一个plane,然后添加一个canvas,在画布中添加一张图片。拖拽图片能将预制件cube放到指定位置。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class DragImage : MonoBehaviour , IBeginDragHandler,IDragHandler,IEndDragHandler
{
// Use this for initialization
// void Start () {
// }
// // Update is called once per frame
// void Update () {
// }
private GameObject gO_cube