Search Unity

Mesh API Arguments and Options

Discussion in 'UI Toolkit' started by Panda_Notaria, Jul 8, 2020.

  1. Panda_Notaria

    Panda_Notaria

    Joined:
    Jul 8, 2020
    Posts:
    1
    I am looking into porting some plotting code from GL to the Mesh API.


    What is the current recommend approach to draw simple lines? I intend for the look of a default Matlab plot.


    I found this example of generating a mesh:

    https://github.com/Unity-Technologi...master/Modules/GraphViewEditor/EdgeControl.cs

    This code has some weirdness to it. Namely

    Code (CSharp):
    1.  
    2. var md = mgc.Allocate((int)wantedLength, (int)indexCount, null, null, MeshGenerationContext.MeshFlags.UVisDisplacement);
    3.  
    4. // ...
    5.  
    6. Color32 flags = new Color32(0, 0, 0, (byte)VertexFlags.LastType);
    7.  
    8. // ...
    9. md.SetNextVertex(new Vertex() { position = new Vector3(pos.x, pos.y, 1), uv = uv, tint = tint, idsFlags = flags });
    10.  
    I can't find that overload of Allocate or Vertex with idsFlags.

    This is notable a experimental element in the ref. source.
     
    Last edited: Jul 8, 2020
  2. SimonDufour

    SimonDufour

    Unity Technologies

    Joined:
    Jun 30, 2020
    Posts:
    575
    The mesh api, while really powerful, is not yet recommended for development. The data in each vertex need to conform to the expectation of the shader and a lot of (undocumented) features are intertwined.

    Because of this, the api is still experimental and subject to breaking changes.

    The allocate method is in UIRMeshGenerationContext.cs