Skip to content

Instantly share code, notes, and snippets.

@MattRix
Created December 30, 2016 02:37
Show Gist options
  • Save MattRix/579e43200875f9f1b3f9f08cfcbb026d to your computer and use it in GitHub Desktop.
Save MattRix/579e43200875f9f1b3f9f08cfcbb026d to your computer and use it in GitHub Desktop.
Example of doing a vertex modifer for Unity UI stuff
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