Example #1
0
    //对拖动开始事件的响应
    //读取信息并赋值给Image
    public void DragAndDrop_OnLeftBeginDrag(Transform tf)
    {
        //判断拖动的是什么格子
        if (tf.transform.tag.Equals("ModuleSlot"))//如果是装备栏,则从装备中提取信息
        {
            ModuleSlot ms = tf.GetComponent <ModuleSlot>();
            if (PlayerManager.instance.ModuleMap[ms.rawIndex, ms.rolIndex] != null)
            {
                Img.sprite = PlayerManager.instance.ModuleMap[ms.rawIndex, ms.rolIndex].Icon;
                this.gameObject.SetActive(true);
            }
            else
            {
                return;
            }
        }
        else if (tf.transform.tag.Equals("ModuleSelection"))//如果是仓库,则从仓库中提取信息
        {
            ModuleSelectUI ms = tf.GetComponent <ModuleSelectUI>();

            if (PlayerManager.instance.ModuleList[ms.Index] != null)
            {
                Img.sprite = PlayerManager.instance.ModuleList[ms.Index].Icon;
                this.gameObject.SetActive(true);
            }
            else
            {
                return;
            }
        }
        else
        {
            return;
        }
    }
Example #2
0
    public void DragAndDrop_OnLeftBeginDrag(Transform tf)
    {
        //icon = new GameObject("Icon", typeof(Image));

        if (tf.transform.tag.Equals("ModuleSlot"))
        {
            ModuleSlot ms = tf.GetComponent <ModuleSlot>();
            if (PlayerManager.instance.ModuleMap[ms.rawIndex, ms.rolIndex] != null)
            {
                icon = new GameObject("Icon", typeof(Image));
                icon.GetComponent <Image>().sprite = PlayerManager.instance.ModuleMap[ms.rawIndex, ms.rolIndex].Icon;
                icon.transform.SetParent(GameObject.Find("Canvas").transform);
                icon.transform.SetAsLastSibling();
            }
            else
            {
                return;
            }
        }
        else if (tf.transform.tag.Equals("ModuleSelection"))
        {
            ModuleSelectUI ms = tf.GetComponent <ModuleSelectUI>();

            if (StorageManager.instance.ModuleList[ms.Index] != null)
            {
                icon = new GameObject("Icon", typeof(Image));
                icon.GetComponent <Image>().sprite = StorageManager.instance.ModuleList[ms.Index].Icon;
                icon.transform.SetParent(GameObject.Find("Canvas").transform);
                icon.transform.SetAsLastSibling();
            }
            else
            {
                return;
            }
        }
        else
        {
            return;
        }
    }