Skip to content

Instantly share code, notes, and snippets.

@karljj1
Created March 12, 2019 10:23
Show Gist options
  • Save karljj1/021322672344cf4c47044353652c8bfd to your computer and use it in GitHub Desktop.
Save karljj1/021322672344cf4c47044353652c8bfd to your computer and use it in GitHub Desktop.
A simple example of how Particles can be used in the UI system.
using UnityEngine;
using UnityEngine.UI;
public class UIParticles : MaskableGraphic
{
public ParticleSystemRenderer particleSystemRenderer;
public bool useTransform;
public Texture texture;
void Update()
{
SetVerticesDirty();
}
public override Texture mainTexture
{
get
{
if (texture)
return texture;
return base.mainTexture;
}
}
protected override void OnPopulateMesh(Mesh m)
{
if (particleSystemRenderer)
{
particleSystemRenderer.BakeMesh(m, useTransform);
//particleSystemRenderer.BakeTrailsMesh
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment