A utility class that can aid in the generation of meshes for the UI.
Namespace: UnityEngine.UI Assembly: UnityEngine.UI.dll Syntaxpublic class VertexHelper : IDisposable
Examples
using UnityEngine;
using UnityEngine.UI;
public class ExampleClass : MonoBehaviour
{
Mesh m;
void Start()
{
Color32 color32 = Color.red;
using (var vh = new VertexHelper())
{
vh.AddVert(new Vector3(0, 0), color32, new Vector2(0f, 0f));
vh.AddVert(new Vector3(0, 100), color32, new Vector2(0f, 1f));
vh.AddVert(new Vector3(100, 100), color32, new Vector2(1f, 1f));
vh.AddVert(new Vector3(100, 0), color32, new Vector2(1f, 0f));
vh.AddTriangle(0, 1, 2);
vh.AddTriangle(2, 3, 0);
vh.FillMesh(m);
}
}
}
Constructors VertexHelper() Declaration VertexHelper(Mesh) Declaration
public VertexHelper(Mesh m)
Parameters Type Name Description Mesh m Properties currentIndexCount
Get the number of indices set on the VertexHelper.
Declarationpublic int currentIndexCount { get; }
Property Value currentVertCount
Current number of vertices in the buffer.
Declarationpublic int currentVertCount { get; }
Property Value Methods AddTriangle(int, int, int)
Add a triangle to the buffer.
Declarationpublic void AddTriangle(int idx0, int idx1, int idx2)
Parameters Type Name Description int idx0
index 0
int idx1index 1
int idx2index 2
AddUIVertexQuad(UIVertex[])Add a quad to the stream.
Declarationpublic void AddUIVertexQuad(UIVertex[] verts)
Parameters Type Name Description UIVertex[] verts
4 Vertices representing the quad.
AddUIVertexStream(List<UIVertex>, List<int>)Add a stream of custom UIVertex and corresponding indices.
Declarationpublic void AddUIVertexStream(List<UIVertex> verts, List<int> indices)
Parameters Type Name Description List<UIVertex> verts
The custom stream of verts to add to the helpers internal data.
List<int> indicesThe custom stream of indices to add to the helpers internal data.
AddUIVertexTriangleStream(List<UIVertex>)Add a list of triangles to the stream.
Declarationpublic void AddUIVertexTriangleStream(List<UIVertex> verts)
Parameters Type Name Description List<UIVertex> verts
Vertices to add. Length should be divisible by 3.
AddVert(UIVertex)Add a single vertex to the stream.
Declarationpublic void AddVert(UIVertex v)
Parameters Type Name Description UIVertex v
The vertex to add
AddVert(Vector3, Color32, Vector4)Add a single vertex to the stream.
Declarationpublic void AddVert(Vector3 position, Color32 color, Vector4 uv0)
Parameters Type Name Description Vector3 position
Position of the vert
Color32 colorColor of the vert
Vector4 uv0UV of the vert
AddVert(Vector3, Color32, Vector4, Vector4, Vector3, Vector4)Add a single vertex to the stream.
Declarationpublic void AddVert(Vector3 position, Color32 color, Vector4 uv0, Vector4 uv1, Vector3 normal, Vector4 tangent)
Parameters Type Name Description Vector3 position
Position of the vert
Color32 colorColor of the vert
Vector4 uv0UV of the vert
Vector4 uv1UV1 of the vert
Vector3 normalNormal of the vert.
Vector4 tangentTangent of the vert
AddVert(Vector3, Color32, Vector4, Vector4, Vector4, Vector4, Vector3, Vector4)Add a single vertex to the stream.
Declarationpublic void AddVert(Vector3 position, Color32 color, Vector4 uv0, Vector4 uv1, Vector4 uv2, Vector4 uv3, Vector3 normal, Vector4 tangent)
Parameters Clear()
Clear all vertices from the stream.
Declaration Dispose()Cleanup allocated memory.
Declaration FillMesh(Mesh)Fill the given mesh with the stream data.
Declarationpublic void FillMesh(Mesh mesh)
Parameters Type Name Description Mesh mesh GetUIVertexStream(List<UIVertex>)
Create a stream of UI vertex (in triangles) from the stream.
Declarationpublic void GetUIVertexStream(List<UIVertex> stream)
Parameters PopulateUIVertex(ref UIVertex, int)
Fill a UIVertex with data from index i of the stream.
Declarationpublic void PopulateUIVertex(ref UIVertex vertex, int i)
Parameters Type Name Description UIVertex vertex
Vertex to populate
int iIndex to populate.
SetUIVertex(UIVertex, int)Set a UIVertex at the given index.
Declarationpublic void SetUIVertex(UIVertex vertex, int i)
Parameters Type Name Description UIVertex vertex
The vertex to fill
int ithe position in the current list to fill.
ImplementsRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4