Add NonTile Mode Prototype

This commit is contained in:
copecone committed 2026-08-10 03:08:42 +09:00
1 parent cb0d9c1c9c
commit 400f952990
4 files changed
+89 -2

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
using System;
using System.Runtime.CompilerServices;
using UnityEngine;
namespace ADOFAIRenderer.Util
{
public static class ParticleUtil
{
private static readonly ConditionalWeakTable<ParticleSystem, ParticleSystemRenderer> Cache = new();
public static ParticleSystemRenderer? GetRenderer(this ParticleSystem ps)
{
if (!ps) return null;
if (Cache.TryGetValue(ps, out var renderer) && renderer) return renderer;
var particleSystems = ps.GetComponents<ParticleSystem>();
var renderers = ps.GetComponents<ParticleSystemRenderer>();
var index = Array.IndexOf(particleSystems, ps);
renderer = index >= 0 && index < renderers.Length ? renderers[index] : ps.GetComponent<ParticleSystemRenderer>();
if (renderer) Cache.Add(ps, renderer);
return renderer;
}
}
}