Example #1
0
    // Start is called before the first frame update
    void Start()
    {
        circleObjList = new List <GameObject>();
        boxList       = new List <Transform>();
        boxColorList  = new List <SpriteRenderer>();
        boxTextList   = new List <Text>();

        boxList.Add(Box.GetComponent <Transform>());
        boxList.Add(Box1.GetComponent <Transform>());
        boxList.Add(Box2.GetComponent <Transform>());
        boxList.Add(Box3.GetComponent <Transform>());

        boxColorList.Add(Box.GetComponent <SpriteRenderer>());
        boxColorList.Add(Box1.GetComponent <SpriteRenderer>());
        boxColorList.Add(Box2.GetComponent <SpriteRenderer>());
        boxColorList.Add(Box3.GetComponent <SpriteRenderer>());

        boxTextList.Add(Box.transform.GetChild(0).gameObject.GetComponent <Text>());
        boxTextList.Add(Box1.transform.GetChild(0).gameObject.GetComponent <Text>());
        boxTextList.Add(Box2.transform.GetChild(0).gameObject.GetComponent <Text>());
        boxTextList.Add(Box3.transform.GetChild(0).gameObject.GetComponent <Text>());

        // 円オブジェクトの作成カウント初期化
        for (int i = 0; i < boxTextList.Count; i++)
        {
            boxTextList[i].text = Random.Range(1, 5 + 1).ToString();
        }
    }