From 7eb41124db06ea794db76788b35ce82a0af2c402 Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Fri, 1 Jul 2022 15:36:37 +0900 Subject: [PATCH 1/6] fix: ParticleSystem reordering and refreshing in inspector does not work for prefab asset --- Scripts/Editor/UIParticleEditor.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Scripts/Editor/UIParticleEditor.cs b/Scripts/Editor/UIParticleEditor.cs index c43a8c7b..f0b40848 100644 --- a/Scripts/Editor/UIParticleEditor.cs +++ b/Scripts/Editor/UIParticleEditor.cs @@ -120,15 +120,15 @@ static void Init() .Select(x => x.GetComponent()) .Where(x => x) .Select(x => x.GetComponentInParent()) - .Where(x => x) + .Where(x => x && x.canvas) .Concat( Selection.gameObjects .Select(x => x.GetComponent()) - .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 @@ protected override void OnEnable() 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 @@ protected override void OnEnable() 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(); } @@ -231,7 +231,7 @@ private static void MaterialField(Rect rect, GUIContent label, SerializedPropert public override void OnInspectorGUI() { var current = target as UIParticle; - if (current == null) return; + if (!current) return; serializedObject.Update(); @@ -319,7 +319,7 @@ public override void OnInspectorGUI() // 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,7 +427,7 @@ private static void WindowFunction(UnityEngine.Object target, SceneView sceneVie { try { - if (s_SerializedObject.targetObjects.Any(x => !x)) return; + if (s_SerializedObject.targetObjects.OfType().Any(x => !x || !x.canvas)) return; s_SerializedObject.Update(); using (new EditorGUILayout.VerticalScope(GUILayout.Width(220f))) From f97e6195e62b5acfa8f3e97bfe3bc4a7dcadf38a Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Fri, 1 Jul 2022 15:37:18 +0900 Subject: [PATCH 2/6] fix: add `Enabled` toggle in overlay window --- Scripts/Editor/UIParticleEditor.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Scripts/Editor/UIParticleEditor.cs b/Scripts/Editor/UIParticleEditor.cs index f0b40848..d9abe573 100644 --- a/Scripts/Editor/UIParticleEditor.cs +++ b/Scripts/Editor/UIParticleEditor.cs @@ -434,6 +434,7 @@ private static void WindowFunction(UnityEngine.Object target, SceneView sceneVie { 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; From c1538a83998608a30dc90944b05f8b75e165cf05 Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Fri, 1 Jul 2022 15:38:11 +0900 Subject: [PATCH 3/6] fix: refresh button does not works in prefab edit mode close #214 --- Scripts/Editor/UIParticleEditor.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Scripts/Editor/UIParticleEditor.cs b/Scripts/Editor/UIParticleEditor.cs index d9abe573..cf9ccc14 100644 --- a/Scripts/Editor/UIParticleEditor.cs +++ b/Scripts/Editor/UIParticleEditor.cs @@ -192,16 +192,10 @@ protected override void OnEnable() 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) @@ -269,9 +263,18 @@ public override void OnInspectorGUI() EditorGUILayout.PropertyField(m_AbsoluteMode); // Target ParticleSystems. + EditorGUI.BeginChangeCheck(); + EditorGUI.BeginDisabledGroup(targets.OfType().Any(x => !x.canvas)); _ro.DoLayoutList(); - + EditorGUI.EndDisabledGroup(); serializedObject.ApplyModifiedProperties(); + if (EditorGUI.EndChangeCheck()) + { + foreach (var uip in targets.OfType()) + { + uip.RefreshParticles(uip.particles); + } + } // Does the shader support UI masks? if (current.maskable && current.GetComponentInParent()) From 550d0c43be35cd07e390ffd5749557c89fee0332 Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Fri, 1 Jul 2022 15:40:06 +0900 Subject: [PATCH 4/6] fix: if `m_Particles` contains null, an error will occur close #214 --- Scripts/UIParticle.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Scripts/UIParticle.cs b/Scripts/UIParticle.cs index fa53467f..af51c189 100644 --- a/Scripts/UIParticle.cs +++ b/Scripts/UIParticle.cs @@ -290,6 +290,7 @@ public void RefreshParticles(List particles) 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) { From a11d2d01ce5f67e3f430bcb0bfdee1ad9abf7cfe Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Fri, 1 Jul 2022 15:55:59 +0900 Subject: [PATCH 5/6] fix: when `UIParticlrRenderer` destroy manually, an error will occur --- Scripts/UIParticle.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Scripts/UIParticle.cs b/Scripts/UIParticle.cs index af51c189..f8ecbe56 100644 --- a/Scripts/UIParticle.cs +++ b/Scripts/UIParticle.cs @@ -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; @@ -322,9 +323,15 @@ internal void UpdateRenderers() { 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); } } @@ -333,6 +340,7 @@ internal void UpdateParticleCount() { for (var i = 0; i < m_Renderers.Count; i++) { + if (!m_Renderers[i]) continue; m_Renderers[i].UpdateParticleCount(); } } @@ -418,6 +426,10 @@ internal UIParticleRenderer GetRenderer(int index) { m_Renderers.Add(UIParticleRenderer.AddRenderer(this, index)); } + if (!m_Renderers[index]) + { + m_Renderers[index] = UIParticleRenderer.AddRenderer(this, index); + } return m_Renderers[index]; } From 4edcef1bbf49519ed2b841e669adb82fdc6a3d9b Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 1 Jul 2022 07:49:12 +0000 Subject: [PATCH 6/6] chore(release): 4.1.4 [skip ci] ## [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)) --- CHANGELOG.md | 11 +++++++++++ package.json | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e869c34f..6dd13a2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +## [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) diff --git a/package.json b/package.json index 5d6e6fc6..ddd47565 100644 --- a/package.json +++ b/package.json @@ -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.4", "unity": "2018.2", "license": "MIT", "repository": {