You've already forked ParticleEffectForUGUI
mirror of
https://github.com/mob-sakai/ParticleEffectForUGUI.git
synced 2026-05-14 20:20:06 +00:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e6da2e158 | ||
|
|
f60d6dfe60 | ||
|
|
c795d24003 | ||
|
|
9e2dbe7758 | ||
|
|
4edcef1bbf | ||
|
|
a11d2d01ce | ||
|
|
550d0c43be | ||
|
|
c1538a8399 | ||
|
|
f97e6195e6 | ||
|
|
7eb41124db |
25
CHANGELOG.md
25
CHANGELOG.md
@@ -1,3 +1,28 @@
|
||||
## [4.1.6](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/4.1.5...4.1.6) (2022-08-10)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix abnormal mesh bounds error ([f60d6df](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/f60d6dfe6030ac89527a4265e414e9a0a20d56db)), closes [#213](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/213) [#218](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/218)
|
||||
|
||||
## [4.1.5](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/4.1.4...4.1.5) (2022-08-10)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix culling for RectMask2D ([9e2dbe7](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/9e2dbe7758eb28a4f6a7c11113d9169847880f96)), closes [#220](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/220)
|
||||
|
||||
## [4.1.4](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/4.1.3...4.1.4) (2022-07-01)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* add `Enabled` toggle in overlay window ([f97e619](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/f97e6195e62b5acfa8f3e97bfe3bc4a7dcadf38a))
|
||||
* if `m_Particles` contains null, an error will occur ([550d0c4](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/550d0c43be35cd07e390ffd5749557c89fee0332)), closes [#214](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/214)
|
||||
* ParticleSystem reordering and refreshing in inspector does not work for prefab asset ([7eb4112](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/7eb41124db06ea794db76788b35ce82a0af2c402))
|
||||
* refresh button does not works in prefab edit mode ([c1538a8](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/c1538a83998608a30dc90944b05f8b75e165cf05)), closes [#214](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/214)
|
||||
* when `UIParticlrRenderer` destroy manually, an error will occur ([a11d2d0](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/a11d2d01ce5f67e3f430bcb0bfdee1ad9abf7cfe))
|
||||
|
||||
## [4.1.3](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/4.1.2...4.1.3) (2022-06-28)
|
||||
|
||||
|
||||
|
||||
@@ -120,15 +120,15 @@ namespace Coffee.UIExtensions
|
||||
.Select(x => x.GetComponent<ParticleSystem>())
|
||||
.Where(x => x)
|
||||
.Select(x => x.GetComponentInParent<UIParticle>())
|
||||
.Where(x => x)
|
||||
.Where(x => x && x.canvas)
|
||||
.Concat(
|
||||
Selection.gameObjects
|
||||
.Select(x => x.GetComponent<UIParticle>())
|
||||
.Where(x => x)
|
||||
.Where(x => x && x.canvas)
|
||||
)
|
||||
.Distinct()
|
||||
.ToArray();
|
||||
return uiParticles.Any() ? new SerializedObject(uiParticles) : null;
|
||||
return 0 < uiParticles.Length ? new SerializedObject(uiParticles) : null;
|
||||
};
|
||||
|
||||
s_SerializedObject = createSerializeObject();
|
||||
@@ -155,9 +155,9 @@ namespace Coffee.UIExtensions
|
||||
|
||||
var sp = serializedObject.FindProperty("m_Particles");
|
||||
_ro = new ReorderableList(sp.serializedObject, sp, true, true, true, true);
|
||||
_ro.elementHeight = EditorGUIUtility.singleLineHeight * 3 + 4;
|
||||
_ro.elementHeight = (EditorGUIUtility.singleLineHeight * 3) + 4;
|
||||
_ro.elementHeightCallback = _ => 3 * (EditorGUIUtility.singleLineHeight + 2);
|
||||
_ro.drawElementCallback = (rect, index, active, focused) =>
|
||||
_ro.drawElementCallback = (rect, index, _, __) =>
|
||||
{
|
||||
EditorGUI.BeginDisabledGroup(sp.hasMultipleDifferentValues);
|
||||
rect.y += 1;
|
||||
@@ -175,7 +175,7 @@ namespace Coffee.UIExtensions
|
||||
rect.y += rect.height + 1;
|
||||
MaterialField(rect, s_ContentTrailMaterial, materials, 1);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
if (materials != null)
|
||||
if (materials != null && materials.serializedObject.hasModifiedProperties)
|
||||
{
|
||||
materials.serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
@@ -192,16 +192,10 @@ namespace Coffee.UIExtensions
|
||||
foreach (UIParticle t in targets)
|
||||
{
|
||||
t.RefreshParticles();
|
||||
EditorUtility.SetDirty(t);
|
||||
}
|
||||
}
|
||||
};
|
||||
_ro.onReorderCallback = _ =>
|
||||
{
|
||||
foreach (UIParticle t in targets)
|
||||
{
|
||||
t.RefreshParticles(t.particles);
|
||||
}
|
||||
};
|
||||
|
||||
// On select UIParticle, refresh particles.
|
||||
foreach (UIParticle t in targets)
|
||||
@@ -231,7 +225,7 @@ namespace Coffee.UIExtensions
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
var current = target as UIParticle;
|
||||
if (current == null) return;
|
||||
if (!current) return;
|
||||
|
||||
serializedObject.Update();
|
||||
|
||||
@@ -269,9 +263,18 @@ namespace Coffee.UIExtensions
|
||||
EditorGUILayout.PropertyField(m_AbsoluteMode);
|
||||
|
||||
// Target ParticleSystems.
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUI.BeginDisabledGroup(targets.OfType<UIParticle>().Any(x => !x.canvas));
|
||||
_ro.DoLayoutList();
|
||||
|
||||
EditorGUI.EndDisabledGroup();
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
foreach (var uip in targets.OfType<UIParticle>())
|
||||
{
|
||||
uip.RefreshParticles(uip.particles);
|
||||
}
|
||||
}
|
||||
|
||||
// Does the shader support UI masks?
|
||||
if (current.maskable && current.GetComponentInParent<Mask>())
|
||||
@@ -319,7 +322,7 @@ namespace Coffee.UIExtensions
|
||||
// Check to use 'TEXCOORD*.zw' components as custom vertex stream.
|
||||
foreach (var psr in allPsRenderers)
|
||||
{
|
||||
if (new SerializedObject(psr).FindProperty("m_UseCustomVertexStreams").boolValue == false) continue;
|
||||
if (!new SerializedObject(psr).FindProperty("m_UseCustomVertexStreams").boolValue) continue;
|
||||
if (psr.activeVertexStreamsCount == 0) continue;
|
||||
psr.GetActiveVertexStreams(s_Streams);
|
||||
|
||||
@@ -427,13 +430,14 @@ namespace Coffee.UIExtensions
|
||||
{
|
||||
try
|
||||
{
|
||||
if (s_SerializedObject.targetObjects.Any(x => !x)) return;
|
||||
if (s_SerializedObject.targetObjects.OfType<UIParticle>().Any(x => !x || !x.canvas)) return;
|
||||
|
||||
s_SerializedObject.Update();
|
||||
using (new EditorGUILayout.VerticalScope(GUILayout.Width(220f)))
|
||||
{
|
||||
var labelWidth = EditorGUIUtility.labelWidth;
|
||||
EditorGUIUtility.labelWidth = 100;
|
||||
EditorGUILayout.PropertyField(s_SerializedObject.FindProperty("m_Enabled"));
|
||||
_xyzMode = DrawFloatOrVector3Field(s_SerializedObject.FindProperty("m_Scale3D"), _xyzMode);
|
||||
EditorGUILayout.PropertyField(s_SerializedObject.FindProperty("m_AbsoluteMode"));
|
||||
EditorGUIUtility.labelWidth = labelWidth;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define SERIALIZE_FIELD_MASKABLE
|
||||
#endif
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Coffee.UIParticleExtensions;
|
||||
using UnityEngine;
|
||||
@@ -290,6 +291,7 @@ namespace Coffee.UIExtensions
|
||||
var j = 0;
|
||||
for (var i = 0; i < particles.Count; i++)
|
||||
{
|
||||
if (!particles[i]) continue;
|
||||
GetRenderer(j++).Set(this, particles[i], false);
|
||||
if (particles[i].trails.enabled)
|
||||
{
|
||||
@@ -321,9 +323,15 @@ namespace Coffee.UIExtensions
|
||||
{
|
||||
if (!isActiveAndEnabled) return;
|
||||
|
||||
if (m_Renderers.Any(x => !x))
|
||||
{
|
||||
RefreshParticles(particles);
|
||||
}
|
||||
|
||||
var bakeCamera = GetBakeCamera();
|
||||
for (var i = 0; i < m_Renderers.Count; i++)
|
||||
{
|
||||
if (!m_Renderers[i]) continue;
|
||||
m_Renderers[i].UpdateMesh(bakeCamera);
|
||||
}
|
||||
}
|
||||
@@ -332,6 +340,7 @@ namespace Coffee.UIExtensions
|
||||
{
|
||||
for (var i = 0; i < m_Renderers.Count; i++)
|
||||
{
|
||||
if (!m_Renderers[i]) continue;
|
||||
m_Renderers[i].UpdateParticleCount();
|
||||
}
|
||||
}
|
||||
@@ -417,6 +426,10 @@ namespace Coffee.UIExtensions
|
||||
{
|
||||
m_Renderers.Add(UIParticleRenderer.AddRenderer(this, index));
|
||||
}
|
||||
if (!m_Renderers[index])
|
||||
{
|
||||
m_Renderers[index] = UIParticleRenderer.AddRenderer(this, index);
|
||||
}
|
||||
return m_Renderers[index];
|
||||
}
|
||||
|
||||
|
||||
@@ -14,15 +14,14 @@ namespace Coffee.UIExtensions
|
||||
internal class UIParticleRenderer : MaskableGraphic
|
||||
{
|
||||
private static readonly CombineInstance[] s_CombineInstances = new CombineInstance[] { new CombineInstance() };
|
||||
//private static ParticleSystem.Particle[] s_Particles = new ParticleSystem.Particle[2048];
|
||||
private static readonly List<Material> s_Materials = new List<Material>(2);
|
||||
private static MaterialPropertyBlock s_Mpb;
|
||||
private static readonly List<UIParticleRenderer> s_Renderers = new List<UIParticleRenderer>();
|
||||
private static readonly Vector3[] s_Corners = new Vector3[4];
|
||||
|
||||
private ParticleSystemRenderer _renderer;
|
||||
private ParticleSystem _particleSystem;
|
||||
internal int _prevParticleCount = 0;
|
||||
//private ParticleSystem _emitter;
|
||||
private int _prevParticleCount = 0;
|
||||
private UIParticle _parent;
|
||||
private int _index;
|
||||
private bool _isTrail;
|
||||
@@ -33,6 +32,7 @@ namespace Coffee.UIExtensions
|
||||
private bool _delay = false;
|
||||
private bool _prewarm = false;
|
||||
private Material _currentMaterialForRendering;
|
||||
private Bounds _lastBounds;
|
||||
|
||||
public override Texture mainTexture
|
||||
{
|
||||
@@ -49,6 +49,37 @@ namespace Coffee.UIExtensions
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private Rect rootCanvasRect
|
||||
{
|
||||
get
|
||||
{
|
||||
s_Corners[0] = transform.TransformPoint(_lastBounds.min.x, _lastBounds.min.y, 0);
|
||||
s_Corners[1] = transform.TransformPoint(_lastBounds.min.x, _lastBounds.max.y, 0);
|
||||
s_Corners[2] = transform.TransformPoint(_lastBounds.max.x, _lastBounds.max.y, 0);
|
||||
s_Corners[3] = transform.TransformPoint(_lastBounds.max.x, _lastBounds.min.y, 0);
|
||||
if (canvas)
|
||||
{
|
||||
var worldToLocalMatrix = canvas.rootCanvas.transform.worldToLocalMatrix;
|
||||
for (var i = 0; i < 4; ++i)
|
||||
s_Corners[i] = worldToLocalMatrix.MultiplyPoint(s_Corners[i]);
|
||||
}
|
||||
var corner1 = (Vector2) s_Corners[0];
|
||||
var corner2 = (Vector2) s_Corners[0];
|
||||
for (var i = 1; i < 4; ++i)
|
||||
{
|
||||
if (s_Corners[i].x < corner1.x)
|
||||
corner1.x = s_Corners[i].x;
|
||||
else if (s_Corners[i].x > corner2.x)
|
||||
corner2.x = s_Corners[i].x;
|
||||
if (s_Corners[i].y < corner1.y)
|
||||
corner1.y = s_Corners[i].y;
|
||||
else if (s_Corners[i].y > corner2.y)
|
||||
corner2.y = s_Corners[i].y;
|
||||
}
|
||||
return new Rect(corner1, corner2 - corner1);
|
||||
}
|
||||
}
|
||||
|
||||
public static UIParticleRenderer AddRenderer(UIParticle parent, int index)
|
||||
{
|
||||
@@ -123,6 +154,7 @@ namespace Coffee.UIExtensions
|
||||
material = null;
|
||||
workerMesh.Clear();
|
||||
canvasRenderer.SetMesh(workerMesh);
|
||||
_lastBounds = new Bounds();
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
@@ -188,6 +220,7 @@ namespace Coffee.UIExtensions
|
||||
Profiler.BeginSample("[UIParticleRenderer] Clear Mesh");
|
||||
workerMesh.Clear();
|
||||
canvasRenderer.SetMesh(workerMesh);
|
||||
_lastBounds = new Bounds();
|
||||
Profiler.EndSample();
|
||||
|
||||
return;
|
||||
@@ -241,7 +274,7 @@ namespace Coffee.UIExtensions
|
||||
}
|
||||
else
|
||||
{
|
||||
s_CombineInstances[0].mesh.Clear();
|
||||
s_CombineInstances[0].mesh.Clear(false);
|
||||
}
|
||||
Profiler.EndSample();
|
||||
|
||||
@@ -269,6 +302,7 @@ namespace Coffee.UIExtensions
|
||||
extents.z = 0;
|
||||
bounds.extents = extents;
|
||||
workerMesh.bounds = bounds;
|
||||
_lastBounds = bounds;
|
||||
}
|
||||
Profiler.EndSample();
|
||||
|
||||
@@ -286,6 +320,7 @@ namespace Coffee.UIExtensions
|
||||
{
|
||||
if (s_Renderers[i] == this) continue;
|
||||
s_Renderers[i].canvasRenderer.SetMesh(workerMesh);
|
||||
s_Renderers[i]._lastBounds = _lastBounds;
|
||||
}
|
||||
|
||||
if (!_parent.canRender)
|
||||
@@ -353,6 +388,17 @@ namespace Coffee.UIExtensions
|
||||
protected override void UpdateGeometry()
|
||||
{
|
||||
}
|
||||
|
||||
public override void Cull(Rect clipRect, bool validRect)
|
||||
{
|
||||
var cull = _lastBounds.extents == Vector3.zero || !validRect || !clipRect.Overlaps(rootCanvasRect, true);
|
||||
if (canvasRenderer.cull == cull) return;
|
||||
|
||||
canvasRenderer.cull = cull;
|
||||
UISystemProfilerApi.AddMarker("MaskableGraphic.cullingChanged", this);
|
||||
onCullStateChanged.Invoke(cull);
|
||||
OnCullingChanged();
|
||||
}
|
||||
|
||||
private Vector3 GetWorldScale()
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "com.coffee.ui-particle",
|
||||
"displayName": "UI Particle",
|
||||
"description": "This plugin provide a component to render particle effect for uGUI.\nThe particle rendering is maskable and sortable, without Camera, RenderTexture or Canvas.",
|
||||
"version": "4.1.3",
|
||||
"version": "4.1.6",
|
||||
"unity": "2018.2",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
|
||||
Reference in New Issue
Block a user