Skip to content

Instantly share code, notes, and snippets.

@HajiyevEl
Forked from MattRix/VertBend.cs
Created August 13, 2023 09:00
Show Gist options
  • Save HajiyevEl/9acd4c90ef1e9709bf4b8c2695e813ad to your computer and use it in GitHub Desktop.
Save HajiyevEl/9acd4c90ef1e9709bf4b8c2695e813ad 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