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
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c795d24003 | ||
|
|
9e2dbe7758 | ||
|
|
4edcef1bbf | ||
|
|
a11d2d01ce | ||
|
|
550d0c43be | ||
|
|
c1538a8399 | ||
|
|
f97e6195e6 | ||
|
|
7eb41124db | ||
|
|
65c60000c2 | ||
|
|
fa2f867bca | ||
|
|
b2b2b0f767 | ||
|
|
fb7f308f09 | ||
|
|
8034228713 | ||
|
|
f526671826 | ||
|
|
81dacb1efe | ||
|
|
48d1994f5f | ||
|
|
f9901a0255 | ||
|
|
3b0f6985f6 | ||
|
|
1879ac8c53 |
47
CHANGELOG.md
47
CHANGELOG.md
@@ -1,3 +1,50 @@
|
|||||||
|
## [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)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* error on drag prefab to scene ([fa2f867](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/fa2f867bcaff437bb9420da1abcef970cdb09ade)), closes [#211](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/211)
|
||||||
|
|
||||||
|
## [4.1.2](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/4.1.1...4.1.2) (2022-06-27)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* error on editor ([8034228](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/80342287137c07d58a7492875a401d80cb134073)), closes [#210](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/210)
|
||||||
|
* incorrect position of world space trail particles ([fb7f308](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/fb7f308f092db8a1512383857b80110cd626ecf9)), closes [#209](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/209)
|
||||||
|
|
||||||
|
## [4.1.1](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/4.1.0...4.1.1) (2022-06-25)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* add absolute mode toggle to overlay window ([48d1994](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/48d1994f5f8751b707b6ef7695b552df731bece9))
|
||||||
|
|
||||||
|
# [4.1.0](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/4.0.1...4.1.0) (2022-06-25)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add relative/absolute particle position mode ([1879ac8](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/1879ac8c538778e386e68cfc989a6f4f974043ca)), closes [#205](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/205)
|
||||||
|
|
||||||
## [4.0.1](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/4.0.0...4.0.1) (2022-06-24)
|
## [4.0.1](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/4.0.0...4.0.1) (2022-06-24)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -65,8 +65,10 @@ Compares this "Baking mesh" approach with the conventional approach:
|
|||||||
* [4.0.0+] Adaptive scaling for UI
|
* [4.0.0+] Adaptive scaling for UI
|
||||||
* [4.0.0+] Mesh sharing group to improve performance
|
* [4.0.0+] Mesh sharing group to improve performance
|
||||||

|

|
||||||
* [4.0.0+] particle attractor component
|
* [4.0.0+] Particle attractor component
|
||||||

|

|
||||||
|
* [4.1.0+] Relative/Absolute particle position mode
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
<br><br><br><br>
|
<br><br><br><br>
|
||||||
@@ -168,6 +170,7 @@ Unity 2018.2 supports embedded packages.
|
|||||||
| Scale | Scale the rendering.<br>When the `3D` toggle is enabled, 3D scale (x,y,z) is supported. |
|
| 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. |
|
| Animatable Properties | If you want update material properties (e.g. `_MainTex_ST`, `_Color`) in AnimationClip, use this to mark the changes. |
|
||||||
| Mesh Sharing | Particle simulation results are shared within the same group.<br>A large number of the same effects can be displayed with a small load.<br>When the `Random` toggle is enabled, it will be grouped randomaly. |
|
| Mesh Sharing | Particle simulation results are shared within the same group.<br>A large number of the same effects can be displayed with a small load.<br>When the `Random` toggle is enabled, it will be grouped randomaly. |
|
||||||
|
| Absolute Mode | The particles will be emitted at the ParticleSystem position.<br>Move the UIParticle/ParticleSystem to move the particle. |
|
||||||
| Rendering Order | The ParticleSystems to be rendered.<br>You can change the rendering order and the materials. |
|
| 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.
|
NOTE: Press `Refresh` button to reconstruct rendering order based on children ParticleSystem's sorting order and z position.
|
||||||
|
|||||||
84
Samples~/Demo/Materials/UIParticle_Demo_Dot.mat
Normal file
84
Samples~/Demo/Materials/UIParticle_Demo_Dot.mat
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!21 &2100000
|
||||||
|
Material:
|
||||||
|
serializedVersion: 6
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: UIParticle_Demo_Dot
|
||||||
|
m_Shader: {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
m_ShaderKeywords:
|
||||||
|
m_LightmapFlags: 4
|
||||||
|
m_EnableInstancingVariants: 0
|
||||||
|
m_DoubleSidedGI: 0
|
||||||
|
m_CustomRenderQueue: 3001
|
||||||
|
stringTagMap: {}
|
||||||
|
disabledShaderPasses: []
|
||||||
|
m_SavedProperties:
|
||||||
|
serializedVersion: 3
|
||||||
|
m_TexEnvs:
|
||||||
|
- _BumpMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailAlbedoMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailMask:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailNormalMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _EmissionMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _MainTex:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _MetallicGlossMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _OcclusionMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _ParallaxMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
m_Floats:
|
||||||
|
- _BumpScale: 1
|
||||||
|
- _ColorMask: 15
|
||||||
|
- _Cutoff: 0.5
|
||||||
|
- _DetailNormalMapScale: 1
|
||||||
|
- _DstBlend: 0
|
||||||
|
- _GlossMapScale: 1
|
||||||
|
- _Glossiness: 0.5
|
||||||
|
- _GlossyReflections: 1
|
||||||
|
- _Metallic: 0
|
||||||
|
- _Mode: 0
|
||||||
|
- _OcclusionStrength: 1
|
||||||
|
- _Parallax: 0.02
|
||||||
|
- _SmoothnessTextureChannel: 0
|
||||||
|
- _SpecularHighlights: 1
|
||||||
|
- _SrcBlend: 1
|
||||||
|
- _Stencil: 0
|
||||||
|
- _StencilComp: 8
|
||||||
|
- _StencilOp: 0
|
||||||
|
- _StencilReadMask: 255
|
||||||
|
- _StencilWriteMask: 255
|
||||||
|
- _UVSec: 0
|
||||||
|
- _UseUIAlphaClip: 0
|
||||||
|
- _ZWrite: 1
|
||||||
|
m_Colors:
|
||||||
|
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||||
8
Samples~/Demo/Materials/UIParticle_Demo_Dot.mat.meta
Normal file
8
Samples~/Demo/Materials/UIParticle_Demo_Dot.mat.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b35a584a784274746b87deef91c15c5c
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 2100000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -14,6 +14,7 @@ public class UIElementDragger : MonoBehaviour, IBeginDragHandler, IDragHandler,
|
|||||||
private Canvas canvas;
|
private Canvas canvas;
|
||||||
public Target m_Target;
|
public Target m_Target;
|
||||||
public Transform m_CustomTarget;
|
public Transform m_CustomTarget;
|
||||||
|
public bool ex2;
|
||||||
|
|
||||||
private void OnEnable()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
@@ -37,6 +38,8 @@ public class UIElementDragger : MonoBehaviour, IBeginDragHandler, IDragHandler,
|
|||||||
rectTransform.localPosition += delta;
|
rectTransform.localPosition += delta;
|
||||||
if (m_CustomTarget)
|
if (m_CustomTarget)
|
||||||
{
|
{
|
||||||
|
if (ex2)
|
||||||
|
delta.Scale(canvas.rootCanvas.transform.localScale);
|
||||||
m_CustomTarget.localPosition += delta;
|
m_CustomTarget.localPosition += delta;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -62,6 +62,7 @@ namespace Coffee.UIExtensions
|
|||||||
private SerializedProperty m_MeshSharing;
|
private SerializedProperty m_MeshSharing;
|
||||||
private SerializedProperty m_GroupId;
|
private SerializedProperty m_GroupId;
|
||||||
private SerializedProperty m_GroupMaxId;
|
private SerializedProperty m_GroupMaxId;
|
||||||
|
private SerializedProperty m_AbsoluteMode;
|
||||||
|
|
||||||
|
|
||||||
private ReorderableList _ro;
|
private ReorderableList _ro;
|
||||||
@@ -119,15 +120,15 @@ namespace Coffee.UIExtensions
|
|||||||
.Select(x => x.GetComponent<ParticleSystem>())
|
.Select(x => x.GetComponent<ParticleSystem>())
|
||||||
.Where(x => x)
|
.Where(x => x)
|
||||||
.Select(x => x.GetComponentInParent<UIParticle>())
|
.Select(x => x.GetComponentInParent<UIParticle>())
|
||||||
.Where(x => x)
|
.Where(x => x && x.canvas)
|
||||||
.Concat(
|
.Concat(
|
||||||
Selection.gameObjects
|
Selection.gameObjects
|
||||||
.Select(x => x.GetComponent<UIParticle>())
|
.Select(x => x.GetComponent<UIParticle>())
|
||||||
.Where(x => x)
|
.Where(x => x && x.canvas)
|
||||||
)
|
)
|
||||||
.Distinct()
|
.Distinct()
|
||||||
.ToArray();
|
.ToArray();
|
||||||
return uiParticles.Any() ? new SerializedObject(uiParticles) : null;
|
return 0 < uiParticles.Length ? new SerializedObject(uiParticles) : null;
|
||||||
};
|
};
|
||||||
|
|
||||||
s_SerializedObject = createSerializeObject();
|
s_SerializedObject = createSerializeObject();
|
||||||
@@ -150,12 +151,13 @@ namespace Coffee.UIExtensions
|
|||||||
m_MeshSharing = serializedObject.FindProperty("m_MeshSharing");
|
m_MeshSharing = serializedObject.FindProperty("m_MeshSharing");
|
||||||
m_GroupId = serializedObject.FindProperty("m_GroupId");
|
m_GroupId = serializedObject.FindProperty("m_GroupId");
|
||||||
m_GroupMaxId = serializedObject.FindProperty("m_GroupMaxId");
|
m_GroupMaxId = serializedObject.FindProperty("m_GroupMaxId");
|
||||||
|
m_AbsoluteMode = serializedObject.FindProperty("m_AbsoluteMode");
|
||||||
|
|
||||||
var sp = serializedObject.FindProperty("m_Particles");
|
var sp = serializedObject.FindProperty("m_Particles");
|
||||||
_ro = new ReorderableList(sp.serializedObject, sp, true, true, true, true);
|
_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.elementHeightCallback = _ => 3 * (EditorGUIUtility.singleLineHeight + 2);
|
||||||
_ro.drawElementCallback = (rect, index, active, focused) =>
|
_ro.drawElementCallback = (rect, index, _, __) =>
|
||||||
{
|
{
|
||||||
EditorGUI.BeginDisabledGroup(sp.hasMultipleDifferentValues);
|
EditorGUI.BeginDisabledGroup(sp.hasMultipleDifferentValues);
|
||||||
rect.y += 1;
|
rect.y += 1;
|
||||||
@@ -173,7 +175,7 @@ namespace Coffee.UIExtensions
|
|||||||
rect.y += rect.height + 1;
|
rect.y += rect.height + 1;
|
||||||
MaterialField(rect, s_ContentTrailMaterial, materials, 1);
|
MaterialField(rect, s_ContentTrailMaterial, materials, 1);
|
||||||
EditorGUI.EndDisabledGroup();
|
EditorGUI.EndDisabledGroup();
|
||||||
if (materials != null)
|
if (materials != null && materials.serializedObject.hasModifiedProperties)
|
||||||
{
|
{
|
||||||
materials.serializedObject.ApplyModifiedProperties();
|
materials.serializedObject.ApplyModifiedProperties();
|
||||||
}
|
}
|
||||||
@@ -190,24 +192,16 @@ namespace Coffee.UIExtensions
|
|||||||
foreach (UIParticle t in targets)
|
foreach (UIParticle t in targets)
|
||||||
{
|
{
|
||||||
t.RefreshParticles();
|
t.RefreshParticles();
|
||||||
|
EditorUtility.SetDirty(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
_ro.onReorderCallback = _ =>
|
|
||||||
{
|
|
||||||
foreach (UIParticle t in targets)
|
|
||||||
{
|
|
||||||
t.RefreshParticles(t.particles);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// On select UIParticle, refresh particles.
|
// On select UIParticle, refresh particles.
|
||||||
if (!Application.isPlaying)
|
foreach (UIParticle t in targets)
|
||||||
{
|
{
|
||||||
foreach (UIParticle t in targets)
|
if (Application.isPlaying || PrefabUtility.GetPrefabAssetType(t) != PrefabAssetType.NotAPrefab) continue;
|
||||||
{
|
t.RefreshParticles(t.particles);
|
||||||
t.RefreshParticles(t.particles);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,7 +225,7 @@ namespace Coffee.UIExtensions
|
|||||||
public override void OnInspectorGUI()
|
public override void OnInspectorGUI()
|
||||||
{
|
{
|
||||||
var current = target as UIParticle;
|
var current = target as UIParticle;
|
||||||
if (current == null) return;
|
if (!current) return;
|
||||||
|
|
||||||
serializedObject.Update();
|
serializedObject.Update();
|
||||||
|
|
||||||
@@ -265,10 +259,22 @@ namespace Coffee.UIExtensions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Target ParticleSystems.
|
// Absolute Mode
|
||||||
_ro.DoLayoutList();
|
EditorGUILayout.PropertyField(m_AbsoluteMode);
|
||||||
|
|
||||||
|
// Target ParticleSystems.
|
||||||
|
EditorGUI.BeginChangeCheck();
|
||||||
|
EditorGUI.BeginDisabledGroup(targets.OfType<UIParticle>().Any(x => !x.canvas));
|
||||||
|
_ro.DoLayoutList();
|
||||||
|
EditorGUI.EndDisabledGroup();
|
||||||
serializedObject.ApplyModifiedProperties();
|
serializedObject.ApplyModifiedProperties();
|
||||||
|
if (EditorGUI.EndChangeCheck())
|
||||||
|
{
|
||||||
|
foreach (var uip in targets.OfType<UIParticle>())
|
||||||
|
{
|
||||||
|
uip.RefreshParticles(uip.particles);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Does the shader support UI masks?
|
// Does the shader support UI masks?
|
||||||
if (current.maskable && current.GetComponentInParent<Mask>())
|
if (current.maskable && current.GetComponentInParent<Mask>())
|
||||||
@@ -316,7 +322,7 @@ namespace Coffee.UIExtensions
|
|||||||
// Check to use 'TEXCOORD*.zw' components as custom vertex stream.
|
// Check to use 'TEXCOORD*.zw' components as custom vertex stream.
|
||||||
foreach (var psr in allPsRenderers)
|
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;
|
if (psr.activeVertexStreamsCount == 0) continue;
|
||||||
psr.GetActiveVertexStreams(s_Streams);
|
psr.GetActiveVertexStreams(s_Streams);
|
||||||
|
|
||||||
@@ -424,15 +430,18 @@ namespace Coffee.UIExtensions
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (s_SerializedObject.targetObjects.Any(x => !x)) return;
|
if (s_SerializedObject.targetObjects.OfType<UIParticle>().Any(x => !x || !x.canvas)) return;
|
||||||
|
|
||||||
s_SerializedObject.Update();
|
s_SerializedObject.Update();
|
||||||
GUILayout.BeginHorizontal(GUILayout.Width(220f));
|
using (new EditorGUILayout.VerticalScope(GUILayout.Width(220f)))
|
||||||
var labelWidth = EditorGUIUtility.labelWidth;
|
{
|
||||||
EditorGUIUtility.labelWidth = 60;
|
var labelWidth = EditorGUIUtility.labelWidth;
|
||||||
_xyzMode = DrawFloatOrVector3Field(s_SerializedObject.FindProperty("m_Scale3D"), _xyzMode);
|
EditorGUIUtility.labelWidth = 100;
|
||||||
EditorGUIUtility.labelWidth = labelWidth;
|
EditorGUILayout.PropertyField(s_SerializedObject.FindProperty("m_Enabled"));
|
||||||
GUILayout.EndHorizontal();
|
_xyzMode = DrawFloatOrVector3Field(s_SerializedObject.FindProperty("m_Scale3D"), _xyzMode);
|
||||||
|
EditorGUILayout.PropertyField(s_SerializedObject.FindProperty("m_AbsoluteMode"));
|
||||||
|
EditorGUIUtility.labelWidth = labelWidth;
|
||||||
|
}
|
||||||
s_SerializedObject.ApplyModifiedProperties();
|
s_SerializedObject.ApplyModifiedProperties();
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#define SERIALIZE_FIELD_MASKABLE
|
#define SERIALIZE_FIELD_MASKABLE
|
||||||
#endif
|
#endif
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using Coffee.UIParticleExtensions;
|
using Coffee.UIParticleExtensions;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@@ -54,6 +55,10 @@ namespace Coffee.UIExtensions
|
|||||||
[SerializeField]
|
[SerializeField]
|
||||||
private int m_GroupMaxId = 0;
|
private int m_GroupMaxId = 0;
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
[Tooltip("The particles will be emitted at the ParticleSystem position.\nMove the UIParticle/ParticleSystem to move the particle.")]
|
||||||
|
private bool m_AbsoluteMode = false;
|
||||||
|
|
||||||
private List<UIParticleRenderer> m_Renderers = new List<UIParticleRenderer>();
|
private List<UIParticleRenderer> m_Renderers = new List<UIParticleRenderer>();
|
||||||
|
|
||||||
#if !SERIALIZE_FIELD_MASKABLE
|
#if !SERIALIZE_FIELD_MASKABLE
|
||||||
@@ -112,6 +117,17 @@ namespace Coffee.UIExtensions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Absolute particle position mode.
|
||||||
|
/// The particles will be emitted at the ParticleSystem position.
|
||||||
|
/// Move the UIParticle/ParticleSystem to move the particle.
|
||||||
|
/// </summary>
|
||||||
|
public bool absoluteMode
|
||||||
|
{
|
||||||
|
get { return m_AbsoluteMode; }
|
||||||
|
set { m_AbsoluteMode = value; }
|
||||||
|
}
|
||||||
|
|
||||||
internal bool useMeshSharing
|
internal bool useMeshSharing
|
||||||
{
|
{
|
||||||
get { return m_MeshSharing != MeshSharing.None; }
|
get { return m_MeshSharing != MeshSharing.None; }
|
||||||
@@ -275,6 +291,7 @@ namespace Coffee.UIExtensions
|
|||||||
var j = 0;
|
var j = 0;
|
||||||
for (var i = 0; i < particles.Count; i++)
|
for (var i = 0; i < particles.Count; i++)
|
||||||
{
|
{
|
||||||
|
if (!particles[i]) continue;
|
||||||
GetRenderer(j++).Set(this, particles[i], false);
|
GetRenderer(j++).Set(this, particles[i], false);
|
||||||
if (particles[i].trails.enabled)
|
if (particles[i].trails.enabled)
|
||||||
{
|
{
|
||||||
@@ -306,9 +323,15 @@ namespace Coffee.UIExtensions
|
|||||||
{
|
{
|
||||||
if (!isActiveAndEnabled) return;
|
if (!isActiveAndEnabled) return;
|
||||||
|
|
||||||
|
if (m_Renderers.Any(x => !x))
|
||||||
|
{
|
||||||
|
RefreshParticles(particles);
|
||||||
|
}
|
||||||
|
|
||||||
var bakeCamera = GetBakeCamera();
|
var bakeCamera = GetBakeCamera();
|
||||||
for (var i = 0; i < m_Renderers.Count; i++)
|
for (var i = 0; i < m_Renderers.Count; i++)
|
||||||
{
|
{
|
||||||
|
if (!m_Renderers[i]) continue;
|
||||||
m_Renderers[i].UpdateMesh(bakeCamera);
|
m_Renderers[i].UpdateMesh(bakeCamera);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -317,6 +340,7 @@ namespace Coffee.UIExtensions
|
|||||||
{
|
{
|
||||||
for (var i = 0; i < m_Renderers.Count; i++)
|
for (var i = 0; i < m_Renderers.Count; i++)
|
||||||
{
|
{
|
||||||
|
if (!m_Renderers[i]) continue;
|
||||||
m_Renderers[i].UpdateParticleCount();
|
m_Renderers[i].UpdateParticleCount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -402,6 +426,10 @@ namespace Coffee.UIExtensions
|
|||||||
{
|
{
|
||||||
m_Renderers.Add(UIParticleRenderer.AddRenderer(this, index));
|
m_Renderers.Add(UIParticleRenderer.AddRenderer(this, index));
|
||||||
}
|
}
|
||||||
|
if (!m_Renderers[index])
|
||||||
|
{
|
||||||
|
m_Renderers[index] = UIParticleRenderer.AddRenderer(this, index);
|
||||||
|
}
|
||||||
return m_Renderers[index];
|
return m_Renderers[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,15 +14,14 @@ namespace Coffee.UIExtensions
|
|||||||
internal class UIParticleRenderer : MaskableGraphic
|
internal class UIParticleRenderer : MaskableGraphic
|
||||||
{
|
{
|
||||||
private static readonly CombineInstance[] s_CombineInstances = new CombineInstance[] { new CombineInstance() };
|
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 readonly List<Material> s_Materials = new List<Material>(2);
|
||||||
private static MaterialPropertyBlock s_Mpb;
|
private static MaterialPropertyBlock s_Mpb;
|
||||||
private static readonly List<UIParticleRenderer> s_Renderers = new List<UIParticleRenderer>();
|
private static readonly List<UIParticleRenderer> s_Renderers = new List<UIParticleRenderer>();
|
||||||
|
private static readonly Vector3[] s_Corners = new Vector3[4];
|
||||||
|
|
||||||
private ParticleSystemRenderer _renderer;
|
private ParticleSystemRenderer _renderer;
|
||||||
private ParticleSystem _particleSystem;
|
private ParticleSystem _particleSystem;
|
||||||
internal int _prevParticleCount = 0;
|
private int _prevParticleCount = 0;
|
||||||
//private ParticleSystem _emitter;
|
|
||||||
private UIParticle _parent;
|
private UIParticle _parent;
|
||||||
private int _index;
|
private int _index;
|
||||||
private bool _isTrail;
|
private bool _isTrail;
|
||||||
@@ -33,6 +32,7 @@ namespace Coffee.UIExtensions
|
|||||||
private bool _delay = false;
|
private bool _delay = false;
|
||||||
private bool _prewarm = false;
|
private bool _prewarm = false;
|
||||||
private Material _currentMaterialForRendering;
|
private Material _currentMaterialForRendering;
|
||||||
|
private Bounds _lastBounds;
|
||||||
|
|
||||||
public override Texture mainTexture
|
public override Texture mainTexture
|
||||||
{
|
{
|
||||||
@@ -49,6 +49,37 @@ namespace Coffee.UIExtensions
|
|||||||
return false;
|
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)
|
public static UIParticleRenderer AddRenderer(UIParticle parent, int index)
|
||||||
{
|
{
|
||||||
@@ -123,6 +154,7 @@ namespace Coffee.UIExtensions
|
|||||||
material = null;
|
material = null;
|
||||||
workerMesh.Clear();
|
workerMesh.Clear();
|
||||||
canvasRenderer.SetMesh(workerMesh);
|
canvasRenderer.SetMesh(workerMesh);
|
||||||
|
_lastBounds = new Bounds();
|
||||||
enabled = false;
|
enabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -188,6 +220,7 @@ namespace Coffee.UIExtensions
|
|||||||
Profiler.BeginSample("[UIParticleRenderer] Clear Mesh");
|
Profiler.BeginSample("[UIParticleRenderer] Clear Mesh");
|
||||||
workerMesh.Clear();
|
workerMesh.Clear();
|
||||||
canvasRenderer.SetMesh(workerMesh);
|
canvasRenderer.SetMesh(workerMesh);
|
||||||
|
_lastBounds = new Bounds();
|
||||||
Profiler.EndSample();
|
Profiler.EndSample();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -249,7 +282,15 @@ namespace Coffee.UIExtensions
|
|||||||
Profiler.BeginSample("[UIParticleRenderer] Combine Mesh");
|
Profiler.BeginSample("[UIParticleRenderer] Combine Mesh");
|
||||||
if (_parent.canSimulate)
|
if (_parent.canSimulate)
|
||||||
{
|
{
|
||||||
s_CombineInstances[0].transform = canvasRenderer.transform.worldToLocalMatrix * GetWorldMatrix(psPos, scale);
|
if (_parent.absoluteMode)
|
||||||
|
{
|
||||||
|
s_CombineInstances[0].transform = canvasRenderer.transform.worldToLocalMatrix * GetWorldMatrix(psPos, scale);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var diff = _particleSystem.transform.position - _parent.transform.position;
|
||||||
|
s_CombineInstances[0].transform = canvasRenderer.transform.worldToLocalMatrix * Matrix4x4.Translate(diff.GetScaled(scale - Vector3.one)) * GetWorldMatrix(psPos, scale);
|
||||||
|
}
|
||||||
workerMesh.CombineMeshes(s_CombineInstances, true, true);
|
workerMesh.CombineMeshes(s_CombineInstances, true, true);
|
||||||
|
|
||||||
workerMesh.RecalculateBounds();
|
workerMesh.RecalculateBounds();
|
||||||
@@ -261,6 +302,7 @@ namespace Coffee.UIExtensions
|
|||||||
extents.z = 0;
|
extents.z = 0;
|
||||||
bounds.extents = extents;
|
bounds.extents = extents;
|
||||||
workerMesh.bounds = bounds;
|
workerMesh.bounds = bounds;
|
||||||
|
_lastBounds = bounds;
|
||||||
}
|
}
|
||||||
Profiler.EndSample();
|
Profiler.EndSample();
|
||||||
|
|
||||||
@@ -278,6 +320,7 @@ namespace Coffee.UIExtensions
|
|||||||
{
|
{
|
||||||
if (s_Renderers[i] == this) continue;
|
if (s_Renderers[i] == this) continue;
|
||||||
s_Renderers[i].canvasRenderer.SetMesh(workerMesh);
|
s_Renderers[i].canvasRenderer.SetMesh(workerMesh);
|
||||||
|
s_Renderers[i]._lastBounds = _lastBounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_parent.canRender)
|
if (!_parent.canRender)
|
||||||
@@ -345,6 +388,17 @@ namespace Coffee.UIExtensions
|
|||||||
protected override void UpdateGeometry()
|
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()
|
private Vector3 GetWorldScale()
|
||||||
{
|
{
|
||||||
@@ -453,14 +507,6 @@ namespace Coffee.UIExtensions
|
|||||||
_prewarm = false;
|
_prewarm = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normal simulation for non-scaling or local spacing.
|
|
||||||
var isScaling = scale != Vector3.one;
|
|
||||||
if (!isScaling || _particleSystem.GetActualSimulationSpace() == ParticleSystemSimulationSpace.Local)
|
|
||||||
{
|
|
||||||
_particleSystem.Simulate(deltaTime, false, false, false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Emitted particles found.
|
// Emitted particles found.
|
||||||
if (_prevParticleCount != _particleSystem.particleCount)
|
if (_prevParticleCount != _particleSystem.particleCount)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ namespace Coffee.UIExtensions
|
|||||||
for (var i = 0; i < s_ActiveParticles.Count; i++)
|
for (var i = 0; i < s_ActiveParticles.Count; i++)
|
||||||
{
|
{
|
||||||
var uip = s_ActiveParticles[i];
|
var uip = s_ActiveParticles[i];
|
||||||
if (!uip.isPrimary || s_UpdatedGroupIds.Contains(uip.groupId)) continue;
|
if (!uip || !uip.canvas || !uip.isPrimary || s_UpdatedGroupIds.Contains(uip.groupId)) continue;
|
||||||
|
|
||||||
s_UpdatedGroupIds.Add(uip.groupId);
|
s_UpdatedGroupIds.Add(uip.groupId);
|
||||||
uip.UpdateTransformScale();
|
uip.UpdateTransformScale();
|
||||||
@@ -73,6 +73,8 @@ namespace Coffee.UIExtensions
|
|||||||
for (var i = 0; i < s_ActiveParticles.Count; i++)
|
for (var i = 0; i < s_ActiveParticles.Count; i++)
|
||||||
{
|
{
|
||||||
var uip = s_ActiveParticles[i];
|
var uip = s_ActiveParticles[i];
|
||||||
|
if (!uip || !uip.canvas) continue;
|
||||||
|
|
||||||
uip.UpdateTransformScale();
|
uip.UpdateTransformScale();
|
||||||
|
|
||||||
if (!uip.useMeshSharing)
|
if (!uip.useMeshSharing)
|
||||||
@@ -97,7 +99,10 @@ namespace Coffee.UIExtensions
|
|||||||
// UpdateParticleCount.
|
// UpdateParticleCount.
|
||||||
for (var i = 0; i < s_ActiveParticles.Count; i++)
|
for (var i = 0; i < s_ActiveParticles.Count; i++)
|
||||||
{
|
{
|
||||||
s_ActiveParticles[i].UpdateParticleCount();
|
var uip = s_ActiveParticles[i];
|
||||||
|
if (!uip || !uip.canvas) continue;
|
||||||
|
|
||||||
|
uip.UpdateParticleCount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"name": "com.coffee.ui-particle",
|
"name": "com.coffee.ui-particle",
|
||||||
"displayName": "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.",
|
"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.0.1",
|
"version": "4.1.5",
|
||||||
"unity": "2018.2",
|
"unity": "2018.2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
Reference in New Issue
Block a user