Esempio n. 1
0
    /// <summary>
    /// 初始化复制的物品
    /// </summary>
    /// <param name="go"></param>
    private void InitNewItem(GameObject go, int num, string tag)
    {
        InventoryItemController tempCtrl = go.GetComponent <InventoryItemController>();
        RectTransform           rect     = go.GetComponent <RectTransform>();

        rect.localPosition = Vector3.zero;  //位置初始化
        tempCtrl.InitId(id);                //id初始化
        tempCtrl.InitName();                //名称初始化,去掉clone
        tempCtrl.InitNum(num);              //数量文本初始化
        tempCtrl.GetComponent <CanvasGroup>().blocksRaycasts = true;
        if (tag == "InVentorySlot")
        {
            tempCtrl.ResetSpriteSize(go.GetComponent <RectTransform>(), 85, 85);
        }
        else
        {
            tempCtrl.ResetSpriteSize(go.GetComponent <RectTransform>(), 70, 62);
        }
    }