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
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
429ff2dd09 | ||
|
|
3f16943ccd | ||
|
|
4b4aebff8c | ||
|
|
46a7dddd11 | ||
|
|
2ec81da048 | ||
|
|
08c4aba8ab | ||
|
|
44889c8a33 |
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -4,7 +4,7 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- preview
|
||||
- master
|
||||
- main
|
||||
- v*.x
|
||||
tags-ignore:
|
||||
- "**"
|
||||
|
||||
14
CHANGELOG.md
14
CHANGELOG.md
@@ -1,3 +1,17 @@
|
||||
# [3.3.0](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/3.2.0...3.3.0) (2020-11-20)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* the particles may disappear unintentionally ([2ec81da](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/2ec81da04877d63593dd863133b6da149dcd79e6)), closes [#117](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/117)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* ignore rendering of particle systems that do not have a SharedMaterial and TrailMaterial ([08c4aba](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/08c4aba8ab9b5a041d4350a72dae62d25530afca)), closes [#118](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/118)
|
||||
* show/hide materials in inspector ([4b4aebf](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/4b4aebff8cdaff9acc696a1094e170e65631135f))
|
||||
* shrink rendering by material ([46a7ddd](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/46a7dddd11c3e030192cd998ae1a79441f5e5c14)), closes [#113](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/113)
|
||||
|
||||
# [3.2.0](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/3.1.1...3.2.0) (2020-11-15)
|
||||
|
||||
|
||||
|
||||
20
README.md
20
README.md
@@ -95,14 +95,11 @@ openupm add com.coffee.ui-particle
|
||||
|
||||
Find the manifest.json file in the Packages folder of your project and add a line to `dependencies` field.
|
||||
|
||||
* Major version: 
|
||||
`"com.coffee.ui-particle": "https://github.com/mob-sakai/ParticleEffectForUGUI.git"`
|
||||
* Preview version: 
|
||||
`"com.coffee.ui-particle": "https://github.com/mob-sakai/ParticleEffectForUGUI.git#preview"`
|
||||
* `"com.coffee.ui-particle": "https://github.com/mob-sakai/ParticleEffectForUGUI.git"`
|
||||
|
||||
To update the package, change suffix `#{version}` to the target version.
|
||||
|
||||
* e.g. `"com.coffee.ui-particle": "https://github.com/mob-sakai/ParticleEffectForUGUI.git#3.0.0",`
|
||||
* `"com.coffee.ui-particle": "https://github.com/mob-sakai/ParticleEffectForUGUI.git#3.3.0",`
|
||||
|
||||
Or, use [UpmGitExtension](https://github.com/mob-sakai/UpmGitExtension) to install and update the package.
|
||||
|
||||
@@ -150,11 +147,16 @@ Unity 2018.2 supports embedded packages.
|
||||
|
||||
`UIParticle` controls the ParticleSystems that is attached to its own game objects and child game objects.
|
||||
|
||||
| Properties | Screenshot |
|
||||
| -- | -- |
|
||||
| **Ignore Canvas Scale:** Ignore the scale of the root canvas. This prevents it from displaying small even in hierarchy scaling mode of ParticleSystem. <br>**Scale:** Scale the rendering. When the `3D` toggle is enabled, 3D scale (x,y,z) is supported. <br>**AnimatableProperties:** If you want update material properties (e.g. `_MainTex_ST`, `_Color`) in AnimationClip, use this to mark the changes. <br>**Rendering Order:** The ParticleSystems to be rendered. You can change the rendering order and the materials. | ![][inspector] |
|
||||

|
||||
|
||||
[inspector]:https://user-images.githubusercontent.com/12690315/95017219-1cea2c00-0693-11eb-9490-c52b8d0fdbb6.png
|
||||
| Properties | Description |
|
||||
| -- | -- |
|
||||
| Maskable | Does this graphic allow masking. |
|
||||
| Ignore Canvas Scale | Ignore the scale of the root canvas.<br>This prevents it from displaying small even in hierarchy scaling mode of `ParticleSystem`. |
|
||||
| Scale | Scale the rendering.<br>When the `3D` toggle is enabled, 3D scale (x,y,z) is supported. |
|
||||
| Animatable Properties | If you want update material properties (e.g. `_MainTex_ST`, `_Color`) in AnimationClip, use this to mark the changes. |
|
||||
| Shrink By Material | Shrink rendering by material.<br>Performance will be improved, but in some cases the rendering is not correct. |
|
||||
| Rendering Order | The ParticleSystems to be rendered.<br>You can change the rendering order and the materials. |
|
||||
|
||||
NOTE: Press `Refresh` button to reconstruct rendering order based on children ParticleSystem's sorting order and z position.
|
||||
|
||||
|
||||
@@ -29,9 +29,11 @@ namespace Coffee.UIExtensions
|
||||
private SerializedProperty _spScale;
|
||||
private SerializedProperty _spIgnoreCanvasScaler;
|
||||
private SerializedProperty _spAnimatableProperties;
|
||||
private SerializedProperty _spShrinkByMaterial;
|
||||
|
||||
private ReorderableList _ro;
|
||||
private bool _xyzMode;
|
||||
private bool _showMaterials;
|
||||
|
||||
private static readonly List<string> s_MaskablePropertyNames = new List<string>
|
||||
{
|
||||
@@ -57,10 +59,15 @@ namespace Coffee.UIExtensions
|
||||
_spScale = serializedObject.FindProperty("m_Scale3D");
|
||||
_spIgnoreCanvasScaler = serializedObject.FindProperty("m_IgnoreCanvasScaler");
|
||||
_spAnimatableProperties = serializedObject.FindProperty("m_AnimatableProperties");
|
||||
_spShrinkByMaterial = serializedObject.FindProperty("m_ShrinkByMaterial");
|
||||
_showMaterials = EditorPrefs.GetBool("Coffee.UIExtensions.UIParticleEditor._showMaterials", true);
|
||||
|
||||
var sp = serializedObject.FindProperty("m_Particles");
|
||||
_ro = new ReorderableList(sp.serializedObject, sp, true, true, true, true);
|
||||
_ro.elementHeight = EditorGUIUtility.singleLineHeight * 3 + 4;
|
||||
_ro.elementHeightCallback = _ => _showMaterials
|
||||
? 3 * (EditorGUIUtility.singleLineHeight + 2)
|
||||
: EditorGUIUtility.singleLineHeight + 2;
|
||||
_ro.drawElementCallback = (rect, index, active, focused) =>
|
||||
{
|
||||
EditorGUI.BeginDisabledGroup(sp.hasMultipleDifferentValues);
|
||||
@@ -68,6 +75,7 @@ namespace Coffee.UIExtensions
|
||||
rect.height = EditorGUIUtility.singleLineHeight;
|
||||
var p = sp.GetArrayElementAtIndex(index);
|
||||
EditorGUI.ObjectField(rect, p, GUIContent.none);
|
||||
if (!_showMaterials) return;
|
||||
|
||||
rect.x += 15;
|
||||
rect.width -= 15;
|
||||
@@ -87,15 +95,15 @@ namespace Coffee.UIExtensions
|
||||
};
|
||||
_ro.drawHeaderCallback += rect =>
|
||||
{
|
||||
#if !UNITY_2019_3_OR_NEWER
|
||||
rect.y -= 1;
|
||||
#endif
|
||||
EditorGUI.LabelField(new Rect(rect.x, rect.y, 150, rect.height), s_ContentRenderingOrder);
|
||||
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
rect = new Rect(rect.width - 55, rect.y, 80, rect.height);
|
||||
#else
|
||||
rect = new Rect(rect.width - 55, rect.y - 1, 80, rect.height);
|
||||
#endif
|
||||
var content = EditorGUIUtility.IconContent(_showMaterials ? "VisibilityOn" : "VisibilityOff");
|
||||
_showMaterials = GUI.Toggle(new Rect(rect.width - 55, rect.y, 24, 20), _showMaterials, content, EditorStyles.label);
|
||||
|
||||
if (GUI.Button(rect, s_ContentRefresh, EditorStyles.miniButton))
|
||||
if (GUI.Button(new Rect(rect.width - 35, rect.y, 60, rect.height), s_ContentRefresh, EditorStyles.miniButton))
|
||||
{
|
||||
foreach (UIParticle t in targets)
|
||||
{
|
||||
@@ -164,6 +172,9 @@ namespace Coffee.UIExtensions
|
||||
t.SetMaterialDirty();
|
||||
}
|
||||
|
||||
// ShrinkByMaterial
|
||||
EditorGUILayout.PropertyField(_spShrinkByMaterial);
|
||||
|
||||
// Target ParticleSystems.
|
||||
_ro.DoLayoutList();
|
||||
|
||||
|
||||
@@ -41,6 +41,9 @@ namespace Coffee.UIExtensions
|
||||
[Tooltip("Particles")] [SerializeField]
|
||||
private List<ParticleSystem> m_Particles = new List<ParticleSystem>();
|
||||
|
||||
[Tooltip("Shrink rendering by material on refresh.\nNOTE: Performance will be improved, but in some cases the rendering is not correct.")] [SerializeField]
|
||||
bool m_ShrinkByMaterial = false;
|
||||
|
||||
#if !SERIALIZE_FIELD_MASKABLE
|
||||
[SerializeField] private bool m_Maskable = true;
|
||||
#endif
|
||||
@@ -81,6 +84,17 @@ namespace Coffee.UIExtensions
|
||||
}
|
||||
}
|
||||
|
||||
public bool shrinkByMaterial
|
||||
{
|
||||
get { return m_ShrinkByMaterial; }
|
||||
set
|
||||
{
|
||||
if (m_ShrinkByMaterial == value) return;
|
||||
m_ShrinkByMaterial = value;
|
||||
RefreshParticles();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Particle effect scale.
|
||||
/// </summary>
|
||||
@@ -217,7 +231,7 @@ namespace Coffee.UIExtensions
|
||||
}
|
||||
|
||||
particles.Exec(p => p.GetComponent<ParticleSystemRenderer>().enabled = !enabled);
|
||||
particles.SortForRendering(transform);
|
||||
particles.SortForRendering(transform, m_ShrinkByMaterial);
|
||||
|
||||
SetMaterialDirty();
|
||||
}
|
||||
@@ -245,12 +259,7 @@ namespace Coffee.UIExtensions
|
||||
if (count == 0 || !isActiveAndEnabled || particles.Count == 0)
|
||||
{
|
||||
canvasRenderer.Clear();
|
||||
|
||||
foreach (var m in s_PrevMaskMaterials)
|
||||
StencilMaterial.Remove(m);
|
||||
|
||||
foreach (var m in s_PrevModifiedMaterials)
|
||||
ModifiedMaterial.Remove(m);
|
||||
ClearPreviousMaterials();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -293,11 +302,18 @@ namespace Coffee.UIExtensions
|
||||
}
|
||||
}
|
||||
|
||||
ClearPreviousMaterials();
|
||||
}
|
||||
|
||||
private void ClearPreviousMaterials()
|
||||
{
|
||||
foreach (var m in s_PrevMaskMaterials)
|
||||
StencilMaterial.Remove(m);
|
||||
s_PrevMaskMaterials.Clear();
|
||||
|
||||
foreach (var m in s_PrevModifiedMaterials)
|
||||
ModifiedMaterial.Remove(m);
|
||||
s_PrevModifiedMaterials.Clear();
|
||||
}
|
||||
|
||||
private Material GetModifiedMaterial(Material baseMaterial, Texture2D texture)
|
||||
|
||||
@@ -164,6 +164,8 @@ namespace Coffee.UIExtensions
|
||||
// No particle to render.
|
||||
var currentPs = particle.particles[i];
|
||||
if (!currentPs || !currentPs.IsAlive() || currentPs.particleCount == 0) continue;
|
||||
var r = currentPs.GetComponent<ParticleSystemRenderer>();
|
||||
if (!r.sharedMaterial && !r.trailMaterial) continue;
|
||||
|
||||
// Calc matrix.
|
||||
Profiler.BeginSample("[UIParticle] Bake Mesh > Calc matrix");
|
||||
@@ -218,7 +220,6 @@ namespace Coffee.UIExtensions
|
||||
#endif
|
||||
|
||||
// Bake main particles.
|
||||
var r = currentPs.GetComponent<ParticleSystemRenderer>();
|
||||
if (CanBakeMesh(r))
|
||||
{
|
||||
Profiler.BeginSample("[UIParticle] Bake Mesh > Bake Main Particles");
|
||||
|
||||
@@ -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) =>
|
||||
{
|
||||
@@ -194,8 +194,15 @@ namespace Coffee.UIParticleExtensions
|
||||
var bRenderer = b.GetComponent<ParticleSystemRenderer>();
|
||||
|
||||
// Render queue: ascending
|
||||
var aMat = aRenderer.sharedMaterial;
|
||||
var bMat = bRenderer.sharedMaterial;
|
||||
var aMat = aRenderer.sharedMaterial ?? aRenderer.trailMaterial;
|
||||
var bMat = bRenderer.sharedMaterial ?? bRenderer.trailMaterial;
|
||||
if (!aMat && !bMat) return 0;
|
||||
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;
|
||||
|
||||
|
||||
@@ -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": "3.2.0",
|
||||
"version": "3.3.0",
|
||||
"unity": "2018.2",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
|
||||
Reference in New Issue
Block a user