Exemple #1
0
    public void GridUIOnLeftBeginDrag(Transform gridTransform) //开始拖动
    {
        if (gridTransform.childCount == 0)                     //格子上没有物品
        {
            isDragNull = true;                                 //禁止拖动空格子
            return;
        }
        else
        {
            isDragNull = false;

            //drag item更新为选择的物品
            Item item = ItemModel.GetItem(gridTransform.name);
            if (item != null)
            {
                dragUI.UpdateIcon(item.iconIndex);
                dragUI.UpdateCount(item.count);

                //将选择的物品从格子上销毁
                Destroy(gridTransform.GetChild(0).gameObject);

                //显示拖动物品
                Vector2 position;
                RectTransformUtility.ScreenPointToLocalPointInRectangle(GameObject.Find("Canvas").transform as RectTransform,
                                                                        Input.mousePosition, null, out position);
                dragUI.SetLocalPosition(position);

                dragUI.ShowItem();
            }
        }
    }
Exemple #2
0
    void Update()
    {
        Vector2 position;

        RectTransformUtility.ScreenPointToLocalPointInRectangle(gameObject.transform as RectTransform, Input.mousePosition, null, out position);
        if (isDrag)
        {
            DragItemUI.show();
            DragItemUI.SetLocalPosition(position);
        }
        else if (isShow)
        {
            TooltipUI.show();
            TooltipUI.SetLocalPosition(position);
        }

        if (isbeibao)
        {
            Beibaoyiman.show();
            time += 1 * Time.deltaTime;
            if (time > 3)
            {
                Beibaoyiman.hidden();
                isbeibao = false;
                time     = 0;
            }
        }
        else
        {
            Beibaoyiman.hidden();
        }
    }
Exemple #3
0
    private void Update()
    {
        Vector2 position;

        RectTransformUtility.ScreenPointToLocalPointInRectangle(GameObject.Find("Canvas").transform as RectTransform, Input.mousePosition, Camera.main, out position);

        if (isDrag)
        {
            DragItemUI.Show();
            DragItemUI.SetLocalPosition(position);
        }
    }
Exemple #4
0
    void Update()
    {
        Vector2 position;

        RectTransformUtility.ScreenPointToLocalPointInRectangle(GameObject.Find("backpackUI").transform as RectTransform, Input.mousePosition, null, out position);
        if (isDrag)
        {
            DragItemUI.show();
            DragItemUI.SetLocalPosition(position);
        }
        else if (isShow)
        {
            TooltipUI.show();
            TooltipUI.SetLocalPosition(position);
        }
    }
Exemple #5
0
    void Update()
    {
        Vector2 position;

        //将鼠标指向的屏幕上的位置的坐标转化为物体坐标并赋值给position
        RectTransformUtility.ScreenPointToLocalPointInRectangle(GameObject.Find("KnapsackUI").transform as RectTransform, Input.mousePosition, null, out position);

        if (isDrag)
        {
            DragItemUI.Show();   //另外创建的DragItemUI显示
            DragItemUI.SetLocalPosition(position);
        }
        else if (isShow)
        {
            TooltipUI.Show();
            TooltipUI.SetLocalPosition(position);  //设置TooltipUI显示时的坐标
        }
    }
Exemple #6
0
 private void Update()
 {
     if (IsDrag)
     {
         Vector2 position;
         //使用转换工具,将鼠标位置坐标转化为UI控件的相对坐标
         RectTransformUtility.ScreenPointToLocalPointInRectangle(GameObject.Find("KnapsackUI").transform as RectTransform, Input.mousePosition, null, out position);
         DragItemUI.Show();
         DragItemUI.SetLocalPosition(position);
     }
     else if (IsShow)
     {
         Vector2 position;
         //使用转换工具,将鼠标位置坐标转化为UI控件的相对坐标
         RectTransformUtility.ScreenPointToLocalPointInRectangle(GameObject.Find("KnapsackUI").transform as RectTransform, Input.mousePosition, null, out position);
         ItemInfoUI.Show();
         ItemInfoUI.SetLocalPosition(position);
         //这里需要将ItemInfo的UI组件的中心设置在左上角
     }
 }