Пример #1
0
    void GenShape()
    {
        var shapeType = AllShapes[Random.Range(0, AllShapes.Length)];
        var size      = Mathf.Sqrt(strength);

        PrimitiveHelper.DecoratePrimitive(gameObject, shapeType);

        // set size
        transform.localScale = Vector3.one * size;

        var bounds = GetComponent <Collider> ().bounds;

        // some primitives have twice the height of others... fix that!
        if (bounds.extents.y / size > 0.51f)
        {
            transform.localScale = Vector3.Scale(transform.localScale, halfSize);
        }
    }