Пример #1
0
    // Use this for initialization
    void Start()
    {
        // make column
        clone = (Transform)Instantiate(column, new Vector3(0, 0, 0), Quaternion.identity);
        clone.transform.localScale = new Vector3(1.0f, tiers * segmentspace / 2.0f, 1.0f);
        towerHeight = clone.GetComponent <MeshRenderer>().bounds.size.y;
        clone.transform.position += new Vector3(0, (towerHeight / 2.0f) + segmentspace, 0);

        // make each layer
        for (int level = 4; level >= 0; level--)
        {
            for (int i = 0; i < 12; i++)
            {
                if (data[level, i] == 1)
                {
                    Transform segClone = (Transform)Instantiate(segment, new Vector3(0, towerHeight - level * segmentspace, 0), Quaternion.Euler(0, i * 30, 0));
                    segClone.transform.localScale = new Vector3(300.0f, 10.0f, 300.0f);
                    segmentHalfHeight             = segClone.transform.localScale.y / 50.0f;
                    segClone.gameObject.tag       = level.ToString();
                    segClone.transform.parent     = clone.transform;
                    Debug.Log(segmentHalfHeight);
                }
            }
        }

        BallPhysics BallPhysics = GameObject.Find("Ball").GetComponent <BallPhysics>();

        BallPhysics.Init();
    }