示例#1
0
    IEnumerator ThreadedAssemble()
    {
        int task = ThreadRunner.CreateThread(new System.Threading.ParameterizedThreadStart(ThreadedSphere), (object)SphereDetail);

        ThreadRunner.StartThread(task);

        while (!ThreadRunner.isComplete(task))
        {
            yield return(null);
        }

        ThreadedSimpleMesh myNewMesh = (ThreadedSimpleMesh)ThreadRunner.FetchData(task);

        Mesh newMesh = myNewMesh.GenerateMesh();
        int  verts   = newMesh.vertexCount;

        if (SaveSphere)
        {
            SaveSphere = false;

            AssetDatabase.CreateAsset(newMesh, "Assets/Meshes/IcoSpheres/IcoSphere-D" + SphereDetail + "-v" + verts + ".asset");
        }

        mf.sharedMesh = newMesh;
    }
示例#2
0
    IEnumerator ThreadedAssemble()
    {
        if (mr == null)
        {
            mr = GetComponent <MeshRenderer>();
        }
        if (mr == null)
        {
            Debug.Log("BadScalingSphere: no MR"); yield break;
        }
        if (mf == null)
        {
            mf = GetComponent <MeshFilter>();
        }
        if (mf == null)
        {
            Debug.Log("BadScalingSphere: no MF"); yield break;
        }


        int task = ThreadRunner.CreateThread(new System.Threading.ParameterizedThreadStart(ThreadedSphere), (object)SphereDetail);

        ThreadRunner.StartThread(task);

        while (!ThreadRunner.isComplete(task))
        {
            yield return(null);
        }

        ThreadedSimpleMesh myNewMesh = (ThreadedSimpleMesh)ThreadRunner.FetchData(task);

        Mesh newMesh = myNewMesh.GenerateMesh();

        int poly = newMesh.triangles.GetLength(0) / 3;

        AssetDatabase.CreateAsset(newMesh, "Assets/Exported/ScalingSphere-" + SphereRadius + "m-" + poly + "v.asset");
        Debug.Log("[GENERATEPYRAMID] Exported mesh: /Assets/Exported/ScalingSphere-" + SphereRadius + "m-" + poly + "v.asset");

        mf.sharedMesh = newMesh;
    }