コード例 #1
0
        public void SetRenderOptions(bool renderMeshValue, bool renderWireframeValue, bool renderNormalsValue)
        {
            bool changed = false;

            if (renderMesh != renderMeshValue || renderWireframe != renderWireframeValue || renderNormals != renderNormalsValue)
            {
                changed = true;
            }
            renderMesh      = renderMeshValue;
            renderWireframe = renderWireframeValue;
            renderNormals   = renderNormalsValue;

            if (changed)
            {
                List <UnityEngine.Material> materials = MaterialUtils.GetMaterials(this);
                MaterialUtils.AssignMaterials(this, materials);
            }
        }
コード例 #2
0
        public bool BuildTriangles()
        {
            if (!trianglesChanged && !mesh.materials.materialsChanged)
            {
                return(false);
            }
            List <UnityEngine.Material> materials = MaterialUtils.GetMaterials(mesh);

            UnityEngine.Material[] materialArray = MaterialUtils.AssignMaterials(mesh, materials);
            mesh.uMesh.subMeshCount = materials.Count;
            List <Materials.MaterialTriangles> materialTriangles = mesh.materials.GetTriangles();

            for (int i = 0; i < materials.Count; i++)
            {
                mesh.uMesh.SetTriangles(materialTriangles[i].triangles.ToArray(), i);
            }
            Selectable selectable = mesh.GetComponent <Selectable>();

            mesh.materials.materialsChanged = false;
            if (selectable != null)
            {
                UnityEngine.Mesh outlineMesh = new UnityEngine.Mesh();
                outlineMesh.vertices  = mesh.uMesh.vertices;
                outlineMesh.triangles = mesh.triangles.triangles.ToArray();
                outlineMesh.RecalculateNormals();
                selectable.outlineMesh         = outlineMesh;
                selectable.unselectedMaterials = materialArray;
                selectable.UpdateSelectedMaterials();
            }
            else
            {
                // BoxSelectionController mesh only
                mesh.uMesh.triangles = triangles.ToArray();
            }
            trianglesChanged = false;
            return(true);
        }