当前位置:   article > 正文

Unity 拖动UI物体(干货)_unity中拖动ui元素进行填空

unity中拖动ui元素进行填空

Unity 拖动UI物体(超级干货)

首先我们先创建一个C#脚本 名字就叫MyMove
代码如下

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

public class MyMove: MonoBehaviour
{
   

    public  GameObject Canvas;
    GameObject InputObject;
    bool b;//鼠标是否在按下状态
    // Start is called before the first frame update
    void Start()
    {
   

    }

    // Update is called once per frame
    void Update()
    {
   
    	//当鼠标按下时 状态为按下状态 InputObject去获取鼠标点击的UI
        if (Input.GetMouseButtonDown(0))
        {
   
            b = true;
            InputObject = GetOverUI
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/704258
推荐阅读
相关标签
  

闽ICP备14008679号