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
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<Int32>)
Creates a new SharedVertex from the specified indices.
Declaration
public SharedVertex(IEnumerable<int> indexes)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Int32> | 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 |
---|---|
Int32 | The length of this collection |
Implements
IsReadOnly
Gets whether this collection is read-only.
Declaration
public bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
Boolean | The value of the IsReadOnly flag. |
Implements
Item[Int32]
Gets and sets the vertex by index.
Declaration
public int this[int i] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
Int32 | i | The index to access. |
Property Value
Type | Description |
---|---|
Int32 |
Methods
Add(Int32)
Adds a new entry using the specified index.
Declaration
public void Add(int item)
Parameters
Type | Name | Description |
---|---|---|
Int32 | item | The index to add. |
Implements
Clear()
Resets this SharedVertex object to an empty collection.
Declaration
public void Clear()
Implements
Contains(Int32)
Returns whether the specified item exists in this collection.
Declaration
public bool Contains(int item)
Parameters
Type | Name | Description |
---|---|---|
Int32 | item | The index of the item to check. |
Returns
Type | Description |
---|---|
Boolean | True if the index was found; false otherwise |
Implements
CopyTo(Int32[], Int32)
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 |
---|---|---|
Int32[] | array | The destination array. |
Int32 | arrayIndex | The index in the destination array where the collection items will be copied. |
Implements
GetEnumerator()
Returns an enumerator that iterates through this collection.
Declaration
public IEnumerator<int> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<Int32> | An IEnumerator object that you can use to iterate through the collection. |
Implements
GetSharedVertexLookup(IList<SharedVertex>, Dictionary<Int32, Int32>)
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<Int32, Int32> | 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(Int32)
Removes the specified item from this collection.
Declaration
public bool Remove(int item)
Parameters
Type | Name | Description |
---|---|---|
Int32 | item | The index of the item to remove. |
Returns
Type | Description |
---|---|
Boolean | True if the index was found and removed; false otherwise |
Implements
ToString()
Returns a string that represents this SharedVertex.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | A comma-delimited string (for example |
Overrides
Explicit Interface Implementations
IEnumerable.GetEnumerator()
Returns an enumerator that iterates through this collection.
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator | An IEnumerator object that you can use to iterate through the collection. |