コード例 #1
0
    public void ShowList(List <List <Dice> > DiceList)
    {
        for (int y = 0; y < DiceList.Count; y++)
        {
            Rows.Add(Instantiate(Row, DiceListUIParent, false));

            DiceUIList.Add(new List <DiceUI>());

            for (int x = 0; x < DiceList[y].Count; x++)
            {
                GameObject currentDice = Instantiate(Dice, Rows[y].transform, false);
                DiceUI     diceUI      = currentDice.GetComponent <DiceUI>();

                diceUI.SetDice(DiceList[y][x]);

                diceUI.DicePointer.y = y;
                diceUI.DicePointer.x = x;

                DiceUIList[y].Add(diceUI);
            }
        }

        //Using coroutine because the unity's layout group only update in next frame, so we have to wait to next frame to get the grid position
        StartCoroutine(IE_AssignPos());
    }
コード例 #2
0
    public void AddDice(Dice newDice, Vector2Int Pos)
    {
        GameObject currentDice = Instantiate(Dice, Rows[Pos.y].transform, false);

        currentDice.transform.SetSiblingIndex(Pos.x);
        DiceUI diceUI = currentDice.GetComponent <DiceUI>();

        diceUI.SetDice(newDice);
        diceUI.DicePointer = Pos;
        Vector3 TargetPos = GetPos(Pos);

        diceUI.transform.position = new Vector3(TargetPos.x, 1080 + 400);
        diceUI.transform.DOMove(TargetPos, 0.5f);
        DiceUIList[Pos.y].Insert(Pos.x, diceUI);
    }