Created
December 30, 2016 02:37
-
-
Save MattRix/579e43200875f9f1b3f9f08cfcbb026d to your computer and use it in GitHub Desktop.
Example of doing a vertex modifer for Unity UI stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine.UI; | |
using System.Collections.Generic; | |
using System; | |
using UnityEngine; | |
public class VertBend : BaseMeshEffect | |
{ | |
public override void ModifyMesh(VertexHelper vh) | |
{ | |
if(!IsActive()) return; | |
int vertCount = vh.currentVertCount; | |
var vert = new UIVertex(); | |
for (int v = 0; v < vertCount; v++) | |
{ | |
vh.PopulateUIVertex(ref vert,v); | |
vert.position.z = (UnityEngine.Random.value-0.5f) * 20f; | |
vh.SetUIVertex(vert,v); | |
} | |
} | |
public void Update() | |
{ | |
var graphic = GetComponent<Graphic>(); | |
graphic.SetVerticesDirty(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment