Search Unity

  1. Check out our Unite Austin 2017 YouTube playlist to catch up on what you missed. More videos coming soon.
    Dismiss Notice
  2. Unity 2017.2 is now released.
    Dismiss Notice
  3. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  6. Unity 2017.3 beta is now available for download.
    Dismiss Notice

UI BaseVertexEffect Change to BaseMeshEffect

Discussion in '5.2 Beta Forum' started by amit1532, Jul 4, 2015.

  1. amit1532

    amit1532

    Joined:
    Jul 19, 2010
    Posts:
    305
    Hello,
    BaseVertexEffect had a virtual method that gets a list of UIVertex
    which i used to add vertices and reorder the existing ones...
    Now I get a mesh and tried to add vertices and colors but it just causes the text to disappear
    I have also tried adding indices but it doesnt work either..
    And I cannot go back to BaseVertexEffect because it is forcing me to use BaseMeshEffect by an error.

    The code i used to have in 5.0: http://pastebin.com/9Z1D130h
     
  2. fpuig

    fpuig

    Joined:
    Dec 26, 2012
    Posts:
    18
    Hi,
    I had your same issue. To solved it, I just followed the same approach the new Shadow effect does.

    Code (csharp):
    1.  
    2.     #if UNITY_5_2
    3.     public partial class MyEffect : BaseMeshEffect
    4.     #else
    5.     public partial class MyEffect : BaseVertexEffect
    6.     #endif
    7.     {
    8.         #if UNITY_5_2
    9.         public override void ModifyMesh (Mesh mesh)
    10.         {
    11.             if (!this.IsActive())
    12.                 return;
    13.  
    14.             List<UIVertex> list = new List<UIVertex>();
    15.             using (VertexHelper vertexHelper = new VertexHelper(mesh))
    16.             {
    17.                 vertexHelper.GetUIVertexStream(list);
    18.             }
    19.  
    20.             ModifyVertices(list);  // calls the old ModifyVertices which was used on pre 5.2
    21.  
    22.             using (VertexHelper vertexHelper2 = new VertexHelper())
    23.             {
    24.                 vertexHelper2.AddUIVertexTriangleStream(list);
    25.                 vertexHelper2.FillMesh(mesh);
    26.             }
    27.         }
    28.         #endif
    29.  
    30.         public void ModifyVertices(List<UIVertex> verts)
    31.         {
    32.                 // you code goes here
    33.         }
    34.  

    Notice that my declaration uses BaseMeshEffect when 5.2 and BaseVertexEffect otherwise.

    Also notice, that the list vertices now has triangles instead of quads.
     
  3. amit1532

    amit1532

    Joined:
    Jul 19, 2010
    Posts:
    305
    Thanks! Didnt notice they updated the code for the shadow effect.
    Ill check that out as soon as I can
     
  4. Iron27

    Iron27

    Joined:
    May 5, 2014
    Posts:
    10
    Thanks for the example fpuig. Is this UI source for 5.2 beta available yet thought? The latest update I see on the Bitbucket repo is from April...

    Edit: Decompiling seems to be good enough for now.
     
    Last edited: Jul 7, 2015
  5. lermy3d

    lermy3d

    Joined:
    Mar 16, 2014
    Posts:
    92
    Thank you so much for sharing the solution! Works great!