You've already forked ParticleEffectForUGUI
mirror of
https://github.com/mob-sakai/ParticleEffectForUGUI.git
synced 2026-05-14 20:20:06 +00:00
# [3.0.0-preview.36](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.35...v3.0.0-preview.36) (2020-09-28) ### Bug Fixes * do not bake particle system to mesh when the alpha is zero ([1775713](1775713c2d)), closes [#102](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/102) * in Unity 2018.x, sample import failed on Windows ([f5861b0](f5861b0add))
64 lines
1.7 KiB
C#
64 lines
1.7 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace Coffee.UIParticleExtensions
|
|
{
|
|
internal class CombineInstanceEx
|
|
{
|
|
private int count;
|
|
public long hash = -1;
|
|
public int index = -1;
|
|
private readonly List<CombineInstance> combineInstances = new List<CombineInstance>(32);
|
|
public Mesh mesh;
|
|
public Matrix4x4 transform;
|
|
|
|
public void Combine()
|
|
{
|
|
switch (count)
|
|
{
|
|
case 0:
|
|
return;
|
|
case 1:
|
|
mesh = combineInstances[0].mesh;
|
|
transform = combineInstances[0].transform;
|
|
return;
|
|
default:
|
|
{
|
|
var cis = CombineInstanceArrayPool.Get(combineInstances);
|
|
mesh = MeshPool.Rent();
|
|
mesh.CombineMeshes(cis, true, true);
|
|
transform = Matrix4x4.identity;
|
|
cis.Clear();
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Clear()
|
|
{
|
|
for (var i = 0; i < combineInstances.Count; i++)
|
|
{
|
|
var inst = combineInstances[i];
|
|
MeshPool.Return(inst.mesh);
|
|
inst.mesh = null;
|
|
combineInstances[i] = inst;
|
|
}
|
|
|
|
combineInstances.Clear();
|
|
|
|
MeshPool.Return(mesh);
|
|
mesh = null;
|
|
|
|
count = 0;
|
|
hash = -1;
|
|
index = -1;
|
|
}
|
|
|
|
public void Push(Mesh mesh, Matrix4x4 transform)
|
|
{
|
|
combineInstances.Add(new CombineInstance {mesh = mesh, transform = transform});
|
|
count++;
|
|
}
|
|
}
|
|
}
|