feat: shrink rendering by material

NOTE: Performance will be improved, but in some cases the rendering is not correct.

Close #113
This commit is contained in:
mob-sakai
2020-11-20 13:11:08 +09:00
parent 2ec81da048
commit 46a7dddd11
3 changed files with 24 additions and 2 deletions

View File

@@ -185,7 +185,7 @@ namespace Coffee.UIParticleExtensions
internal static class ParticleSystemExtensions
{
public static void SortForRendering(this List<ParticleSystem> self, Transform transform)
public static void SortForRendering(this List<ParticleSystem> self, Transform transform, bool sortByMaterial)
{
self.Sort((a, b) =>
{
@@ -200,6 +200,9 @@ namespace Coffee.UIParticleExtensions
if (!aMat) return -1;
if (!bMat) return 1;
if (sortByMaterial)
return aMat.GetInstanceID() - bMat.GetInstanceID();
if (aMat.renderQueue != bMat.renderQueue)
return aMat.renderQueue - bMat.renderQueue;