Example #1
0
    public static ShapeObjectM CreateArrayCount(Vector3 position, Vector3 forward, int uCount, int vCount, Vector3 size)
    {
        List <ShapeObject> sobs      = new List <ShapeObject>();
        GameObject         container = new GameObject();
        ShapeObjectM       som       = container.AddComponent <ShapeObjectM>();
        //GameObject unit = Instantiate<GameObject>(prefab,container.transform);
        //gos.Add(unit);

        float   stepU          = 1f / (float)uCount;
        float   stepV          = 1f / (float)vCount;
        Vector3 unitLocalScale = new Vector3(stepU, stepV, 1);

        float sizeU = size.x / (float)uCount;
        float sizeV = size.y / (float)vCount;

        Vector3 usize = new Vector3(sizeU, sizeV, 1);

        //float sizeU = size.x / uCount;
        //float sizeV = size.y / vCount;
        //ShapeObject o = SOBox.Create(Vector3.zero, unitLocalScale, new Vector3(0, 0, 1));
        //sobs.Add(o);
        for (int i = 0; i < vCount; i++)
        {
            for (int j = 0; j < uCount; j++)
            {
                if (i == 0 && j == 0)
                {
                    continue;
                }
                //ShapeObject dup = o.Clone();
                //dup.Position= new Vector3(j * stepU, i * stepV, 0);
                //dup.transform.parent = som.transform;
                Vector3 pos = new Vector3(j * stepU, i * stepV, 0);
                //ShapeObject o = SOComponent.Create(pos, usize, new Vector3(0, 0, 1));
                ShapeObject o = ShapeObject.CreateComponent();
                o.name             = "component";
                o.Position         = pos;
                o.Size             = usize;
                o.transform.parent = som.transform;
                sobs.Add(o);
            }
        }
        som.transform.localScale = size;
        som.transform.position   = position;
        som.transform.LookAt(position + forward);
        som.components = sobs;
        return(som);
    }