docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class Submesh

    Defines a set of indices and material.

    Inheritance
    object
    Submesh
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: UnityEngine.ProBuilder
    Assembly: Unity.ProBuilder.dll
    Syntax
    [Serializable]
    public sealed class Submesh

    Constructors

    Submesh(int, MeshTopology, IEnumerable<int>)

    Creates a new Submesh from a submesh index for the material, the topology, and a set of indices.

    Declaration
    public Submesh(int submeshIndex, MeshTopology topology, IEnumerable<int> indexes)
    Parameters
    Type Name Description
    int submeshIndex

    The index of this submesh that corresponds to the sharedMaterials property.

    MeshTopology topology

    The topology of this submesh. ProBuilder only recognizes Triangles and Quads.

    IEnumerable<int> indexes

    The triangles or quads.

    Submesh(Mesh, int)

    Creates a new Submesh from a source mesh and a submesh index for the material.

    Declaration
    public Submesh(Mesh mesh, int subMeshIndex)
    Parameters
    Type Name Description
    Mesh mesh

    The source mesh.

    int subMeshIndex

    Which submesh to read from.

    Properties

    indexes

    Gets or sets the indices making up this submesh. Use the topology property to find out whether the submesh contains triangles or quads.

    Declaration
    public IEnumerable<int> indexes { get; set; }
    Property Value
    Type Description
    IEnumerable<int>

    submeshIndex

    Gets or sets the index in the sharedMaterials array that this submesh aligns with.

    Declaration
    public int submeshIndex { get; set; }
    Property Value
    Type Description
    int

    topology

    Gets or sets the topology (whether this submesh is made with triangles or quads).

    Declaration
    public MeshTopology topology { get; set; }
    Property Value
    Type Description
    MeshTopology

    Methods

    GetSubmeshes(IEnumerable<Face>, int, MeshTopology)

    Creates an array of submeshes from a set of faces. Currently only Quads and Triangles are supported.

    Declaration
    public static Submesh[] GetSubmeshes(IEnumerable<Face> faces, int submeshCount, MeshTopology preferredTopology = MeshTopology.Triangles)
    Parameters
    Type Name Description
    IEnumerable<Face> faces

    The faces to be included in the list of submeshes. This method handles group submeshes by comparing the material property of each face.

    int submeshCount

    The number of submeshes to create. Usually you can set this value to the length of the sharedMaterials array.

    MeshTopology preferredTopology

    By default, ProBuilder creates triangles, but you can set this value to false to construct quads. However, ProBuilder falls back to creating triangles if it can't represent some faces in quad format.

    Returns
    Type Description
    Submesh[]

    An array of Submeshes.

    Exceptions
    Type Condition
    NotImplementedException

    Thrown in the event that a MeshTopology other than Quads or Triangles is passed.

    ToString()

    Returns a string that represents this Submesh.

    Declaration
    public override string ToString()
    Returns
    Type Description
    string

    A comma-delimited string (for example "[subMeshIndex],[topology],[indices]").

    Overrides
    object.ToString()
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)