C# VertexHelper Mesh

Which namespace is required for VertexHelper functions?

I get this error:

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class Vectorgrapics : MonoBehaviour {

    // Use this for initialization
    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);
        }
    }
  
    // Update is called once per frame
    void Update () {
  
    }
}

It’s in UnityEngine.UI, which it looks like you have. Are you using an old version of Unity?

I am using the Unity version 5.0.2f1.

Edit: When I used Unity 5.3.5f1, it worked.

But can u tell me, if I have to create a new Mesh, or to use a specific mesh, to draw the quad to the UI?
The VertexHelper.FillMesh(m) needs a mesh object.

Maybe a Unity Dev can improve the VertexHelper definition?
It would be better, when the documentation examples work without any undocumented attributes. So the reader didn´t has to guess about the functionality of this subject.

I would be thankful, if someone has an example, how to use Gui Vertex, to draw polygon objects to the screen.

1 Like

Does anyone know what the 2nd vector parameter (param #3) in the AddVert() function does? I cant quite figure it out

Texture UV coordinates

1 Like