Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Bug GetUIVertexStream not giving correct vertex positions?

Discussion in 'UGUI & TextMesh Pro' started by SpookyCat, Feb 9, 2023.

  1. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,701
    I am doing a simple script that is based of the UI Image component in an attempt to something with the vertices of the image object. To that end I use the IMeshModifier so I can use the ModifyMesh(VertexHelper vh) function. All works fine I can get the image showing in Unity and ModifyMesh is called and it gives me 4 vertices as expected but vertex 3 and 4 are the same value which is clearly not true for a quad.
    Here is a screenshot showing the output of the script below and you can see the last two values are the same.
    Screenshot 2023-02-09 142608.png
    And the simple script.
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3. using System.Collections.Generic;
    4.  
    5. [ExecuteInEditMode]
    6. public class BendUI : Image, IMeshModifier
    7. {
    8.     public GameObject    uiObj;
    9.  
    10.     public void ModifyMesh(Mesh mesh)
    11.     {
    12.     }
    13.  
    14.     public void ModifyMesh(VertexHelper vh)
    15.     {
    16.         Debug.Log("mod mesh vh count " + vh.currentVertCount);
    17.  
    18.         List<UIVertex> verts = new List<UIVertex>();
    19.         vh.GetUIVertexStream(verts);
    20.  
    21.         for ( int i = 0; i < vh.currentVertCount; i++ )
    22.         {
    23.             Debug.Log(i + " " + verts[i].position);
    24.         }
    25.     }
    26. }
    Is this a known bug or have I done something wrong? Can't see what it is a very simple script.