• 使用Mesh 生成雷达图


    private Vertor3[] m_verts;
    private Vertor2[] m_UV;
    private Vector3[] meshIndicte;
    private bool m_change = false;
    private meshFilter m_meshFilter;
    private Mesh m_mesh;
    private MeshRender meshRender;
    public Material m_material;

    public void SetChatData(Verctor3 [] verts)
    {

    if (verts == null || verts.Length < 3)
    return;
    m_verts = new Vertor3[verts.Length +1];
    for (int i = 0; i < verts.Length; i++)
    {
    m_verts[i] = verts[i];
    }

    m_verts [verts.Length -1] = new Vector3();

    m_UV = new Vertor2[m_verts.Length+1];
    int val = m_UV.Length / 4;
    for (int i = 0; i< m_UV.Length -1;i++)
    {
    if (i <= val)
    {
    m_UV[i] = new Vertor2(0, 0) + new Vertor2(0, 1) * (i*1.0f/val);
    }
    else if (i <= 2 * val)
    {
    m_UV[i] = new Vertor2(1,0) + new Vertor2(0, 1) * ((i-val) * 1.0f / val);
    }
    else if (i <= 3 * val)
    {
    m_UV[i] = new Vertor2(1, 1) - new Vertor2(1, 0) * ((i-2*val) * 1.0f / val);
    }
    else if (i <= 4 * val)
    {
    m_UV[i] = new Vertor2(0, 1) - new Vertor2(0, 1) * ((i-3*val) * 1.0f / val);
    }

    m_UV[m_UV.Length - 1] = new Vertor2(0.5f,0.5f);

    meshIndicte = new Vector3[3*(m_UV.Length-1)];

    int index = 0;
    for (int i = 0; i< m_UV.Length; i++)
    {
    meshIndicte[index] = m_UV.Length - 1;

    meshIndicte[index + 1] = i;

    if (i == m_UV.Length - 2)
    {
    meshIndicte[index + 2] = 0;
    }
    else
    {
    meshIndicte[index + 2] = i + 1;

    }
    index += 3;
    }
    m_change = true;

    }


    void Update()
    {
    if (m_change)
    {
    m_change = false;
    meshRender.enable = true;
    mesh.vert = m_verts;
    mesh.uv = m_UV;
    mesh.setIndices(meshIndicte,MeshTopology.Triangle,0);
    mesh.RecalculateBounds();
    }

    }


    void Star()
    {
    m_mesh = new Mesh();
    if (m_meshFilter != null)
    m_meshFilter.mesh = m_mesh;
    }


    void Awake()
    {
    meshRender = gameObject.GetComponent<MeshRender>();
    if (meshRender == null)
    meshRender = gameObject.AddComponent<MeshRender>();
    meshRender.material = m_material;
    m_meshFilter = gameObject.GetComponent<MeshFilter>();
    if(m_meshFilter == null)
    m_meshFilter = gameObject.AddComponent<MeshFilter>();

    }

    }

  • 相关阅读:
    Failed to convert WOFF 2.0 font to SFNT 字体图标显示不出来
    每日一字:困
    每日一字:biáng
    sqlserver数据类型简记
    每日一字:天
    可以作为今生目标的一句话
    每日一字:惑
    [转载]优秀程序员的12中能力
    每日一字:怒
    [转载]像树一样活着
  • 原文地址:https://www.cnblogs.com/DOGame/p/9407057.html
Copyright © 2020-2023  润新知