BaseVertexEffect Change to BaseMeshEffect

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: Outline - Pastebin.com

Hi,
I had your same issue. To solved it, I just followed the same approach the new Shadow effect does.

    #if UNITY_5_2
    public partial class MyEffect : BaseMeshEffect
    #else
    public partial class MyEffect : BaseVertexEffect
    #endif
    {
        #if UNITY_5_2
        public override void ModifyMesh (Mesh mesh)
        {
            if (!this.IsActive())
                return;

            List<UIVertex> list = new List<UIVertex>();
            using (VertexHelper vertexHelper = new VertexHelper(mesh))
            {
                vertexHelper.GetUIVertexStream(list);
            }

            ModifyVertices(list);  // calls the old ModifyVertices which was used on pre 5.2

            using (VertexHelper vertexHelper2 = new VertexHelper())
            {
                vertexHelper2.AddUIVertexTriangleStream(list);
                vertexHelper2.FillMesh(mesh);
            }
        }
        #endif

        public void ModifyVertices(List<UIVertex> verts)
        {
                // you code goes here
        }

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

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

6 Likes

Thanks! Didnt notice they updated the code for the shadow effect.
Ill check that out as soon as I can

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.

Thank you so much for sharing the solution! Works great!