Class SharedVertex
Defines associations between vertex positions that are coincident. The indexes stored in this collection correspond to the positions array.
Inherited Members
Namespace: UnityEngine.ProBuilder
Assembly: Unity.ProBuilder.dll
Syntax
[Serializable]
public sealed class SharedVertex : ICollection<int>, IEnumerable<int>, IEnumerable
Remarks
Coincident vertices are vertices that share the same coordinate position, but are separate entries in the vertex array.
Constructors
SharedVertex(IEnumerable<int>)
Creates a new SharedVertex from the specified indices.
Declaration
public SharedVertex(IEnumerable<int> indexes)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<int> | indexes | An array of indices to set. |
SharedVertex(SharedVertex)
Creates a new SharedVertex from the specified SharedVertex object.
Declaration
public SharedVertex(SharedVertex sharedVertex)
Parameters
Type | Name | Description |
---|---|---|
SharedVertex | sharedVertex | The SharedVertex object to copy. |
Properties
Count
Gets the number of items in this collection.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
int | The length of this collection |
IsReadOnly
Gets whether this collection is read-only.
Declaration
public bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
bool | The value of the IsReadOnly flag. |
this[int]
Gets and sets the vertex by index.
Declaration
public int this[int i] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
int | i | The index to access. |
Property Value
Type | Description |
---|---|
int |
Methods
Add(int)
Adds a new entry using the specified index.
Declaration
public void Add(int item)
Parameters
Type | Name | Description |
---|---|---|
int | item | The index to add. |
Clear()
Resets this SharedVertex object to an empty collection.
Declaration
public void Clear()
Contains(int)
Returns whether the specified item exists in this collection.
Declaration
public bool Contains(int item)
Parameters
Type | Name | Description |
---|---|---|
int | item | The index of the item to check. |
Returns
Type | Description |
---|---|
bool | True if the index was found; false otherwise |
CopyTo(int[], int)
Copies the elements of this collection to an array, starting at the specified arrayIndex
.
Declaration
public void CopyTo(int[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
int[] | array | The destination array. |
int | arrayIndex | The index in the destination array where the collection items will be copied. |
GetEnumerator()
Returns an enumerator that iterates through this collection.
Declaration
public IEnumerator<int> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<int> | An IEnumerator object that you can use to iterate through the collection. |
GetSharedVertexLookup(IList<SharedVertex>, Dictionary<int, int>)
Creates a lookup Dictionary in order to quickly find the index of a SharedVertex
in the
sharedVertices array using a vertex index.
Declaration
public static void GetSharedVertexLookup(IList<SharedVertex> sharedVertices, Dictionary<int, int> lookup)
Parameters
Type | Name | Description |
---|---|---|
IList<SharedVertex> | sharedVertices | A collection of SharedVertex values. |
Dictionary<int, int> | lookup | A Dictionary where the 'key' represents an index in the Mesh positions array, and the 'value' is the index of its placement in the sharedVertices array. |
GetSharedVerticesWithPositions(IList<Vector3>)
Creates a new array of SharedVertex objects by comparing points in the specified positions collection.
Declaration
public static SharedVertex[] GetSharedVerticesWithPositions(IList<Vector3> positions)
Parameters
Type | Name | Description |
---|---|---|
IList<Vector3> | positions | A collection of Vector3 positions to test for equality. |
Returns
Type | Description |
---|---|
SharedVertex[] | A new SharedVertex array where each item is a list of indices that share the same position. |
Examples
var mesh = gameObject.AdComponent<ProBuilderMesh>();
mesh.SetPositions(myNewPositions);
mesh.SetFaces(myNewFaces);
mesh.SetSharedIndexes(SharedVertex.GetSharedVerticesWithPositions(myNewPositions));
Remove(int)
Removes the specified item from this collection.
Declaration
public bool Remove(int item)
Parameters
Type | Name | Description |
---|---|---|
int | item | The index of the item to remove. |
Returns
Type | Description |
---|---|
bool | True if the index was found and removed; false otherwise |
ToString()
Returns a string that represents this SharedVertex.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | A comma-delimited string (for example |