コード例 #1
0
    void Start()
    {
        //Add the objects to the combined mesh
        //Must have previously baked textures for these in the editor
        meshbaker.AddDeleteGameObjects(objsToMove, null, true);
        meshbaker.AddDeleteGameObjects(new GameObject[] { objWithChangingUVs }, null, true);

        MeshFilter mf = objWithChangingUVs.GetComponent <MeshFilter>();

        m   = mf.sharedMesh;
        uvs = m.uv;

        //apply the changes we made this can be slow. See documentation
        meshbaker.Apply();

        //same with multi mesh baker
        multiMeshBaker.AddDeleteGameObjects(objsToMove, null, true);
        multiMeshBaker.AddDeleteGameObjects(new GameObject[] { objWithChangingUVs }, null, true);

        mf  = objWithChangingUVs.GetComponent <MeshFilter>();
        m   = mf.sharedMesh;
        uvs = m.uv;

        multiMeshBaker.Apply();
    }
コード例 #2
0
    IEnumerator largeNumber()
    {
        while (true)
        {
            yield return(new WaitForSeconds(1.5f));

            //Delete every third object
            mbd.AddDeleteGameObjects(null, objs, true);
            mbd.Apply();

            yield return(new WaitForSeconds(1.5f));

            //Add objects back
            mbd.AddDeleteGameObjects(objs, null, true);
            mbd.Apply();
        }
    }
コード例 #3
0
    IEnumerator BakeLoad()
    {
        readyToBake = false;

        //sendObjects to Meshbaker
        mbd.AddDeleteGameObjects(objectsArray, null, true);
        mbd.Apply();
        objectsArray = null;
        yield return(new WaitForSeconds(1.5f));

        readyToBake = true;
    }
コード例 #4
0
    void Start()
    {
        mbd = GetComponentInChildren <MB3_MultiMeshBaker>();

        // instantiate game objects
        int dim = 10;

        GameObject[] gos = new GameObject[dim * dim];
        for (int i = 0; i < dim; i++)
        {
            for (int j = 0; j < dim; j++)
            {
                GameObject go = (GameObject)Instantiate(prefab);
                gos[i * dim + j] = go.GetComponentInChildren <MeshRenderer>().gameObject;
                float randx = Random.Range(-4f, 4f);
                float randz = Random.Range(-4f, 4f);
                go.transform.position = (new Vector3(3f * i + randx, 0, 3f * j + randz));
                float randrot = Random.Range(0, 360);
                go.transform.rotation = Quaternion.Euler(0, randrot, 0);
                Vector3 randscale = Vector3.one + Vector3.one * GaussianValue() * .15f;
                go.transform.localScale = randscale;
                //put every third object in a list so we can add and delete it later
                if ((i * dim + j) % 3 == 0)
                {
                    objsInCombined.Add(gos[i * dim + j]);
                }
            }
        }
        //add objects to combined mesh
        mbd.AddDeleteGameObjects(gos, null, true);
        mbd.Apply();

        objs = objsInCombined.ToArray();
        //start routine which will periodically add and delete objects
        StartCoroutine(largeNumber());
    }