Exemplo n.º 1
0
    void OnWizardCreate()
    {
        GameObject shape = new GameObject();

        if (openingAngle > 0 && openingAngle < 180)
        {
            radiusTop    = 0;
            radiusBottom = length * Mathf.Tan(openingAngle * Mathf.Deg2Rad / 2);
        }

        Mesh mesh;

        /*string meshName = shape.name + numVertices + "v" + radiusTop + "t" + radiusBottom + "b" + length + "l" + length +
         *  (outside ? "o" : "") + (inside ? "i" : "");
         *      string meshPrefabPath = "Assets/Editor/" + meshName + ".asset";
         *      mesh = (Mesh)AssetDatabase.LoadAssetAtPath(meshPrefabPath, typeof(Mesh));*/

        //if(mesh==null)
        //{
        mesh = MeshTools.MakeConeOrFrustum(numVertices, radiusTop, radiusBottom, length, openingAngle, outside, inside);
        //AssetDatabase.CreateAsset(mesh, meshPrefabPath);
        //AssetDatabase.SaveAssets();
        //}

        MeshFilter mf = shape.AddComponent <MeshFilter>();

        mf.mesh = mesh;

        shape.AddComponent <MeshRenderer>();

        /*if(addCollider)
         * {
         *      MeshCollider mc=newCone.AddComponent<MeshCollider>();
         *      mc.sharedMesh=mf.sharedMesh;
         * }*/

        Selection.activeObject = shape;
    }