pull/225/head
mob-sakai 2022-06-11 22:32:14 +09:00
parent 7b21c500ef
commit 01459b06b8
4 changed files with 33 additions and 21 deletions

View File

@ -223,13 +223,7 @@ namespace Coffee.UIExtensions
.ToArray();
// Animated properties
EditorGUI.BeginChangeCheck();
AnimatedPropertiesEditor.DrawAnimatableProperties(m_AnimatableProperties, mats);
if (EditorGUI.EndChangeCheck())
{
foreach (UIParticle t in targets)
t.SetMaterialDirty();
}
// Target ParticleSystems.
_ro.DoLayoutList();

View File

@ -194,7 +194,7 @@ namespace Coffee.UIExtensions
for (var i = 0; i < m_Renderers.Count; i++)
{
GetRenderer(i).Clear();
GetRenderer(i).Clear(i);
}
var j = 0;
@ -206,21 +206,24 @@ namespace Coffee.UIExtensions
GetRenderer(j++).Set(this, particles[i], true);
}
}
}
public void UpdateRenderers()
internal void UpdateTransformScale()
{
var newScale = Vector3.one;
//var newScale = Vector3.one;
//if (uiScaling)
{
newScale = transform.parent.lossyScale.Inverse();
}
//{
// newScale = transform.parent.lossyScale.Inverse();
//}
var newScale = transform.parent.lossyScale.Inverse();
if (transform.localScale != newScale)
{
transform.localScale = newScale;
}
}
internal void UpdateRenderers()
{
var bakeCamera = GetBakeCamera();
for (var i = 0; i < m_Renderers.Count; i++)
{
@ -248,7 +251,7 @@ namespace Coffee.UIExtensions
{
_tracker.Clear();
UIParticleUpdater.Unregister(this);
m_Renderers.ForEach(r=>r.Clear());
m_Renderers.ForEach(r => r.Clear());
UnregisterDirtyMaterialCallback(UpdateRendererMaterial);
base.OnDisable();
@ -282,11 +285,11 @@ namespace Coffee.UIExtensions
}
}
private UIParticleRenderer GetRenderer(int index)
internal UIParticleRenderer GetRenderer(int index)
{
if (m_Renderers.Count <= index)
{
m_Renderers.Add(UIParticleRenderer.AddRenderer(this));
m_Renderers.Add(UIParticleRenderer.AddRenderer(this, index));
}
return m_Renderers[index];
}

View File

@ -15,13 +15,14 @@ namespace Coffee.UIExtensions
{
private static readonly CombineInstance[] s_CombineInstances = new CombineInstance[] { new CombineInstance() };
private static ParticleSystem.Particle[] s_Particles = new ParticleSystem.Particle[2048];
private static List<Material> s_Materials = new List<Material>(2);
private static readonly List<Material> s_Materials = new List<Material>(2);
private static MaterialPropertyBlock s_Mpb;
private ParticleSystemRenderer _renderer;
private ParticleSystem _particleSystem;
//private ParticleSystem _emitter;
private UIParticle _parent;
private int _index;
private bool _isTrail;
private Material _modifiedMaterial;
private Vector3 _prevScale;
@ -46,7 +47,7 @@ namespace Coffee.UIExtensions
}
}
public static UIParticleRenderer AddRenderer(UIParticle parent)
public static UIParticleRenderer AddRenderer(UIParticle parent, int index)
{
// Create renderer object.
var go = new GameObject("UIParticleRenderer", typeof(UIParticleRenderer))
@ -65,6 +66,7 @@ namespace Coffee.UIExtensions
// Add renderer component.
var renderer = go.GetComponent<UIParticleRenderer>();
renderer._parent = parent;
renderer._index = index;
return renderer;
}
@ -96,7 +98,7 @@ namespace Coffee.UIExtensions
return modifiedMaterial;
}
public void Clear()
public void Clear(int index = -1)
{
if (_renderer)
{
@ -105,6 +107,10 @@ namespace Coffee.UIExtensions
_parent = null;
_particleSystem = null;
_renderer = null;
if (0 <= index )
{
_index = index;
}
//_emitter = null;
material = null;

View File

@ -10,6 +10,14 @@ namespace Coffee.UIExtensions
static readonly List<UIParticle> s_ActiveParticles = new List<UIParticle>();
private static int frameCount = 0;
public static int uiParticleCount
{
get
{
return s_ActiveParticles.Count;
}
}
public static void Register(UIParticle particle)
{
if (!particle) return;
@ -41,16 +49,17 @@ namespace Coffee.UIExtensions
Profiler.BeginSample("[UIParticle] Refresh");
for (var i = 0; i < s_ActiveParticles.Count; i++)
{
var uip = s_ActiveParticles[i];
try
{
s_ActiveParticles[i].UpdateRenderers();
uip.UpdateTransformScale();
uip.UpdateRenderers();
}
catch (Exception e)
{
Debug.LogException(e);
}
}
Profiler.EndSample();
}
}