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. Dismiss Notice

What does VertexHelper.GetUIVertexStream actually do

Discussion in 'UGUI & TextMesh Pro' started by liortal, Oct 14, 2015.

  1. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,559
    ZL5787 likes this.
  2. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,683
    You can see the source in the UI Bitbucket.

    All this function does is extract the UIVertext data from the mesh in to a copy List. Updating this list does not affect the base mesh.
    So update the basemesh, you need to call VertextHelper.SetUIVertex(index)

    If you want to pull out a single vertex and manipulate it, you need to use PopulateUIVertex to pull out the UIVertext info, then call SetUIVertex to update it.

    It has been noted, that this constant rebuilding of the UI MESH is not the most performant thing, so some caching should be used. But without the patch or 5.3 UI source, it's not clear as to the best approach that is currently being used bu Unity.
     
  3. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Docs need improving.
     
    laurentlavigne likes this.
  4. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,683
    Also need the source for the patch release, as the base 5.2.1 UI code there is soo out of date since the first patch release.
     
    hippocoder likes this.
  5. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,559
    What is the relation between the number of vertices of the given mesh, and the amount of "UI vertices" returned in the list that is passed to this method?

    Why Is the given text mesh constructed differently (e.g: different number of vertices) than what i'm getting back from this method ?
     
  6. wikmanyo

    wikmanyo

    Joined:
    Nov 17, 2012
    Posts:
    65
    GetUIVertexStream takes a nice optimized mesh with shared verts and completely ruins it. Dont call it. Ever.

    They should probably rename it GetUnoptimisedUIVertexStream() or GetBloatedUIVertexStream()

    :)
     
  7. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,683
    1-1.
    A UIVertex is simple a struct made up of all the vertex information in a Mesh, from Vertices, normal's, colour, etc
    Code (CSharp):
    1.     public struct UIVertex
    2.     {
    3.         public static UIVertex simpleVert;
    4.         public Color32 color;
    5.         public Vector3 normal;
    6.         public Vector3 position;
    7.         public Vector4 tangent;
    8.         public Vector2 uv0;
    9.         public Vector2 uv1;
    10.     }
    These are just the mesh elements needed for UI.
    Personally, I was happy with the last change which just used the base mesh and allowed uniform access to mesh data, the same as 3D stuff, but hay ho
     
    wikmanyo likes this.
  8. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,683
    It's useful if you want to loop through all the vertex information to make / set changes. In fact it's the only way now since they removed access to the base mesh (unless I missed something). you just cannot change anything through it.
     
  9. wikmanyo

    wikmanyo

    Joined:
    Nov 17, 2012
    Posts:
    65
    If you do a GetUIVertexStream() and then a SetUIVertexStream() you will see exactly what it does... ;)
     
  10. wikmanyo

    wikmanyo

    Joined:
    Nov 17, 2012
    Posts:
    65
    100% agree.

    UIVertex is just not required. UIVertexHelper is... pants.
     
    Senshi likes this.
  11. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,559
    While debugging, this doesn't look like the case:
    upload_2015-10-14_20-54-59.png

    After calling GetUIVertexStream these are the results:
    upload_2015-10-14_20-55-26.png

    The mesh has 28 vertices, while the list that was initialized contains 42 vertices. What could be the reason for this difference ?
     
  12. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,683
    Interesting, although that code is a little out of date, as the Patch release removed the mesh from scope and passes an instance of the VertexHelper now :S
    Code (CSharp):
    1. protected override void OnPopulateMesh(VertexHelper vh)
    Your stats are interesting though, as if there is some optimization done in the conversion in to the UIVertex list.
    Will have to test on 5.2.1P / 5.3 and see if the same is true.
     
  13. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,559
    How is that an optimization if there are more vertices? :) BTW i am on 5.2.1
     
    Last edited: Oct 14, 2015
  14. NeilW

    NeilW

    Joined:
    May 29, 2014
    Posts:
    40
    It gives you back 6 verts per quad rather than 4 - as wikmanyo was alluding to the shared verts are no longer shared
     
    liortal likes this.
  15. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,559
    That's what i was looking for. Understood now, thanks!
     
  16. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,683
    lol, I read it backwards #FaceSlap
     
  17. Democide

    Democide

    Joined:
    Jan 29, 2013
    Posts:
    315
    Ah. So infuriating. Installed 5.2, updated a few scripts. And now it's all junk again, because I need to rewrite everything for the VertexHelper? Why Unity, Why?
     
    Last edited: Oct 21, 2015
  18. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,559
    i don't think it's such a big update to get it working...
     
  19. Democide

    Democide

    Joined:
    Jan 29, 2013
    Posts:
    315
    If the vertexHelper documentation would be better, maybe ;)
     
  20. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,683
    Doubt we'll see a doc update until 5.2.2 at the earliest
     
  21. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,559
    5.2.2 just came out today BTW
     
  22. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,683
    Yeah spotted that, AFTER I posted :p
    Sadly the docs have NOT been updated (which is crazy) and the UI source still hasn't got any update.
    @Tim C any update on when the docs for the changes since 5.2.1P1 or the source are likely to be available? We've been without accurate docs since the first patch release.
     
  23. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,559
  24. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,683
    Darn it :D.
    Ahh well, maybe @phil-Unity can chase :D
    #SinkingShip?
     
  25. Democide

    Democide

    Joined:
    Jan 29, 2013
    Posts:
    315
    That does explain things ;)