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:
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
using System;
using UnityEngine;
using UnityEngine.UIElements;
using System.Collections.Generic;
using UnityEngine.Profiling;
namespace UnityEditor.Experimental.GraphView
{
public class EdgeControl : VisualElement
{
private struct EdgeCornerSweepValues
{
public Vector2 circleCenter;
public double sweepAngle;
public double startAngle;
public double endAngle;
This file has been truncated. show original
This code has some weirdness to it. Namely
var md = mgc.Allocate((int)wantedLength, (int)indexCount, null, null, MeshGenerationContext.MeshFlags.UVisDisplacement);
// ...
Color32 flags = new Color32(0, 0, 0, (byte)VertexFlags.LastType);
// ...
md.SetNextVertex(new Vertex() { position = new Vector3(pos.x, pos.y, 1), uv = uv, tint = tint, idsFlags = flags });
I can’t find that overload of Allocate or Vertex with idsFlags .
This is notable a experimental element in the ref. source.
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