You've already forked ParticleEffectForUGUI
mirror of
https://github.com/mob-sakai/ParticleEffectForUGUI.git
synced 2026-05-15 04:30:09 +00:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6a1fef4150 | ||
|
|
3184ba94ae | ||
|
|
6126af9f37 | ||
|
|
c6b816c312 | ||
|
|
5d5eb34590 | ||
|
|
5c3232faf3 | ||
|
|
ac58475539 | ||
|
|
5607dc4eed | ||
|
|
4e4b9eb2a7 | ||
|
|
3fac6e4773 | ||
|
|
45c56bbd85 | ||
|
|
2b8d3b1385 | ||
|
|
c710787b5b | ||
|
|
107f901fe3 |
37
CHANGELOG.md
37
CHANGELOG.md
@@ -1,3 +1,40 @@
|
|||||||
|
## [4.5.1](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/4.5.0...4.5.1) (2023-12-23)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* fix material for mesh sharing group ([6126af9](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/6126af9f376dd4c100a1b9d19d9499bdef7d5566))
|
||||||
|
* the changes made to the material used by the ParticleSystem are not immediately reflected ([3184ba9](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/3184ba94ae08264223c0c71443ad70acc1a1ccb2)), closes [#280](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/280)
|
||||||
|
|
||||||
|
# [4.5.0](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/4.4.0...4.5.0) (2023-12-23)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* incorrect rendering of world-space simulated particles while animating scale ([ac58475](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/ac584755393d87bda2e80d9653370b7e4c68912f)), closes [#285](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/285)
|
||||||
|
* remove obsolete warning ([5d5eb34](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/5d5eb34590b7cefb0e4ac26c0441e104176ce522))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Automatically generated objects are no longer editable (NotEditable). ([5607dc4](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/5607dc4eed0c086b4651941953df6c7d535712e0))
|
||||||
|
* support IMeshModifier ([5c3232f](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/5c3232faf3d2cfad1e3e1a9349b8346c7982a608)), closes [#282](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/282)
|
||||||
|
|
||||||
|
# [4.4.0](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/4.3.0...4.4.0) (2023-11-08)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* support 'Active Apply Color Space' for linear color space ([45c56bb](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/45c56bbd850202365751ea019baf5131b2eb9fbe))
|
||||||
|
|
||||||
|
# [4.3.0](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/4.2.2...4.3.0) (2023-11-08)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* added 'autoScalingMode (None, Transform.localScale, UIParticle.scale)' instead of 'autoScaling' ([107f901](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/107f901fe3232223322681edc4bf908642474298))
|
||||||
|
* reset transform.localScale on upgrading v3.x to v4.x ([c710787](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/c710787b5ba496cf73e7eb43458bb3958139baa9)), closes [#277](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/277)
|
||||||
|
|
||||||
## [4.2.2](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/4.2.1...4.2.2) (2023-10-25)
|
## [4.2.2](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/4.2.1...4.2.2) (2023-10-25)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -286,13 +286,13 @@ UIParticle does not support all built-in shaders except for `UI/Default`.
|
|||||||
If their use is detected, an error is displayed in the inspector.
|
If their use is detected, an error is displayed in the inspector.
|
||||||
Use UI shaders instead.
|
Use UI shaders instead.
|
||||||
|
|
||||||
#### UV.zw components will be discarded
|
#### (2019.4 or earlier) UV.zw components will be discarded
|
||||||
|
|
||||||
UIParticleRenderer renders the particles based on UIVertex.
|
UIParticleRenderer renders the particles based on UIVertex.
|
||||||
Therefore, only xy components is available for each UV in the shader. (zw components will be discarded).
|
Therefore, only xy components is available for each UV in the shader. (zw components will be discarded).
|
||||||
So unfortunately UIParticles will not work well with some shaders.
|
So unfortunately UIParticles will not work well with some shaders.
|
||||||
|
|
||||||
#### Custom vertex streams
|
#### (2019.4 or earlier) Custom vertex streams
|
||||||
|
|
||||||
When using custom vertex streams, you can fill zw components with "unnecessary" data.
|
When using custom vertex streams, you can fill zw components with "unnecessary" data.
|
||||||
https://github.com/mob-sakai/ParticleEffectForUGUI/issues/191
|
https://github.com/mob-sakai/ParticleEffectForUGUI/issues/191
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ namespace Coffee.UIExtensions
|
|||||||
private SerializedProperty _groupId;
|
private SerializedProperty _groupId;
|
||||||
private SerializedProperty _groupMaxId;
|
private SerializedProperty _groupMaxId;
|
||||||
private SerializedProperty _positionMode;
|
private SerializedProperty _positionMode;
|
||||||
private SerializedProperty _autoScaling;
|
private SerializedProperty _autoScalingMode;
|
||||||
private ReorderableList _ro;
|
private ReorderableList _ro;
|
||||||
private bool _showMax;
|
private bool _showMax;
|
||||||
|
|
||||||
@@ -153,7 +153,7 @@ namespace Coffee.UIExtensions
|
|||||||
_groupId = serializedObject.FindProperty("m_GroupId");
|
_groupId = serializedObject.FindProperty("m_GroupId");
|
||||||
_groupMaxId = serializedObject.FindProperty("m_GroupMaxId");
|
_groupMaxId = serializedObject.FindProperty("m_GroupMaxId");
|
||||||
_positionMode = serializedObject.FindProperty("m_PositionMode");
|
_positionMode = serializedObject.FindProperty("m_PositionMode");
|
||||||
_autoScaling = serializedObject.FindProperty("m_AutoScaling");
|
_autoScalingMode = serializedObject.FindProperty("m_AutoScalingMode");
|
||||||
|
|
||||||
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)
|
||||||
@@ -271,7 +271,7 @@ namespace Coffee.UIExtensions
|
|||||||
EditorGUILayout.PropertyField(_positionMode);
|
EditorGUILayout.PropertyField(_positionMode);
|
||||||
|
|
||||||
// Auto Scaling
|
// Auto Scaling
|
||||||
DrawAutoScaling(_autoScaling, targets.OfType<UIParticle>());
|
DrawAutoScaling(_autoScalingMode, targets.OfType<UIParticle>());
|
||||||
|
|
||||||
// Target ParticleSystems.
|
// Target ParticleSystems.
|
||||||
EditorGUI.BeginChangeCheck();
|
EditorGUI.BeginChangeCheck();
|
||||||
@@ -332,8 +332,6 @@ namespace Coffee.UIExtensions
|
|||||||
DestroyUIParticle(current);
|
DestroyUIParticle(current);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #203: When using linear color space, the particle colors are not output correctly.
|
|
||||||
// To fix, set 'Apply Active Color Space' in renderer module to false.
|
|
||||||
var allPsRenderers = targets.OfType<UIParticle>()
|
var allPsRenderers = targets.OfType<UIParticle>()
|
||||||
.SelectMany(x => x.particles)
|
.SelectMany(x => x.particles)
|
||||||
.Where(x => x)
|
.Where(x => x)
|
||||||
@@ -341,16 +339,6 @@ namespace Coffee.UIExtensions
|
|||||||
.ToArray();
|
.ToArray();
|
||||||
if (0 < allPsRenderers.Length)
|
if (0 < allPsRenderers.Length)
|
||||||
{
|
{
|
||||||
var so = new SerializedObject(allPsRenderers);
|
|
||||||
var sp = so.FindProperty("m_ApplyActiveColorSpace");
|
|
||||||
label = "When using linear color space, the particle colors are not output correctly.\n" +
|
|
||||||
"To fix, set 'Apply Active Color Space' in renderer module to false.";
|
|
||||||
if (FixButton(sp.boolValue || sp.hasMultipleDifferentValues, label))
|
|
||||||
{
|
|
||||||
sp.boolValue = false;
|
|
||||||
so.ApplyModifiedProperties();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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)
|
||||||
{
|
{
|
||||||
@@ -478,16 +466,17 @@ namespace Coffee.UIExtensions
|
|||||||
|
|
||||||
private static void DrawAutoScaling(SerializedProperty prop, IEnumerable<UIParticle> uiParticles)
|
private static void DrawAutoScaling(SerializedProperty prop, IEnumerable<UIParticle> uiParticles)
|
||||||
{
|
{
|
||||||
|
var isTransformMode = prop.intValue == (int)UIParticle.AutoScalingMode.Transform;
|
||||||
EditorGUI.BeginChangeCheck();
|
EditorGUI.BeginChangeCheck();
|
||||||
EditorGUILayout.PropertyField(prop);
|
EditorGUILayout.PropertyField(prop);
|
||||||
if (!EditorGUI.EndChangeCheck()) return;
|
if (!EditorGUI.EndChangeCheck() || !isTransformMode) return;
|
||||||
|
|
||||||
// on changed true->false, reset scale.
|
// on changed true->false, reset scale.
|
||||||
EditorApplication.delayCall += () =>
|
EditorApplication.delayCall += () =>
|
||||||
{
|
{
|
||||||
foreach (var uip in uiParticles)
|
foreach (var uip in uiParticles)
|
||||||
{
|
{
|
||||||
if (!uip || uip.autoScaling) continue;
|
if (!uip) continue;
|
||||||
uip.transform.localScale = Vector3.one;
|
uip.transform.localScale = Vector3.one;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -509,7 +498,7 @@ namespace Coffee.UIExtensions
|
|||||||
EditorGUILayout.PropertyField(s_SerializedObject.FindProperty("m_Enabled"));
|
EditorGUILayout.PropertyField(s_SerializedObject.FindProperty("m_Enabled"));
|
||||||
s_XYZMode = DrawFloatOrVector3Field(s_SerializedObject.FindProperty("m_Scale3D"), s_XYZMode);
|
s_XYZMode = DrawFloatOrVector3Field(s_SerializedObject.FindProperty("m_Scale3D"), s_XYZMode);
|
||||||
EditorGUILayout.PropertyField(s_SerializedObject.FindProperty("m_PositionMode"));
|
EditorGUILayout.PropertyField(s_SerializedObject.FindProperty("m_PositionMode"));
|
||||||
DrawAutoScaling(s_SerializedObject.FindProperty("m_AutoScaling"), uiParticles);
|
DrawAutoScaling(s_SerializedObject.FindProperty("m_AutoScalingMode"), uiParticles);
|
||||||
EditorGUIUtility.labelWidth = labelWidth;
|
EditorGUIUtility.labelWidth = labelWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,13 +7,13 @@ namespace Coffee.UIParticleExtensions
|
|||||||
{
|
{
|
||||||
private static readonly List<MatEntry> s_Entries = new List<MatEntry>();
|
private static readonly List<MatEntry> s_Entries = new List<MatEntry>();
|
||||||
|
|
||||||
public static Material Add(Material baseMat, Texture texture, int id)
|
public static Material Add(Material baseMat, Texture texture, int id, int props)
|
||||||
{
|
{
|
||||||
MatEntry e;
|
MatEntry e;
|
||||||
for (var i = 0; i < s_Entries.Count; i++)
|
for (var i = 0; i < s_Entries.Count; i++)
|
||||||
{
|
{
|
||||||
e = s_Entries[i];
|
e = s_Entries[i];
|
||||||
if (e.baseMat != baseMat || e.texture != texture || e.id != id) continue;
|
if (e.baseMat != baseMat || e.texture != texture || e.id != id || e.props != props) continue;
|
||||||
++e.count;
|
++e.count;
|
||||||
return e.customMat;
|
return e.customMat;
|
||||||
}
|
}
|
||||||
@@ -24,6 +24,7 @@ namespace Coffee.UIParticleExtensions
|
|||||||
baseMat = baseMat,
|
baseMat = baseMat,
|
||||||
texture = texture,
|
texture = texture,
|
||||||
id = id,
|
id = id,
|
||||||
|
props = props,
|
||||||
customMat = new Material(baseMat)
|
customMat = new Material(baseMat)
|
||||||
{
|
{
|
||||||
name = $"{baseMat.name}_{id}",
|
name = $"{baseMat.name}_{id}",
|
||||||
@@ -64,6 +65,7 @@ namespace Coffee.UIParticleExtensions
|
|||||||
public int count;
|
public int count;
|
||||||
public Material customMat;
|
public Material customMat;
|
||||||
public int id;
|
public int id;
|
||||||
|
public int props;
|
||||||
public Texture texture;
|
public Texture texture;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using Coffee.UIParticleExtensions;
|
using Coffee.UIParticleExtensions;
|
||||||
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Rendering;
|
using UnityEngine.Rendering;
|
||||||
using UnityEngine.Serialization;
|
using UnityEngine.Serialization;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
using Random = UnityEngine.Random;
|
||||||
|
|
||||||
[assembly: InternalsVisibleTo("Coffee.UIParticle.Editor")]
|
[assembly: InternalsVisibleTo("Coffee.UIParticle.Editor")]
|
||||||
|
|
||||||
@@ -33,6 +36,13 @@ namespace Coffee.UIExtensions
|
|||||||
Absolute
|
Absolute
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum AutoScalingMode
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
UIParticle,
|
||||||
|
Transform
|
||||||
|
}
|
||||||
|
|
||||||
[HideInInspector]
|
[HideInInspector]
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
internal bool m_IsTrail;
|
internal bool m_IsTrail;
|
||||||
@@ -82,10 +92,17 @@ namespace Coffee.UIExtensions
|
|||||||
private PositionMode m_PositionMode = PositionMode.Relative;
|
private PositionMode m_PositionMode = PositionMode.Relative;
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
[Tooltip("Transform.lossyScale (=world scale) is automatically set to (1, 1, 1), " +
|
[Tooltip("Prevent the root-Canvas scale from affecting the hierarchy-scaled ParticleSystem.")]
|
||||||
"to prevent the root-Canvas scale from affecting the hierarchy-scaled ParticleSystem.")]
|
|
||||||
private bool m_AutoScaling = true;
|
private bool m_AutoScaling = true;
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
[Tooltip("Transform: Transform.lossyScale (=world scale) will be set to (1, 1, 1)." +
|
||||||
|
"UIParticle: UIParticle.scale will be adjusted.")]
|
||||||
|
private AutoScalingMode m_AutoScalingMode = AutoScalingMode.Transform;
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
private bool m_ResetScaleOnEnable;
|
||||||
|
|
||||||
private readonly List<UIParticleRenderer> _renderers = new List<UIParticleRenderer>();
|
private readonly List<UIParticleRenderer> _renderers = new List<UIParticleRenderer>();
|
||||||
private int _groupId;
|
private int _groupId;
|
||||||
private Camera _orthoCamera;
|
private Camera _orthoCamera;
|
||||||
@@ -166,16 +183,30 @@ namespace Coffee.UIExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Transform.lossyScale (=world scale) will be set to (1, 1, 1) on update.
|
/// Prevents the root-Canvas scale from affecting the hierarchy-scaled ParticleSystem.
|
||||||
/// It prevents the root-Canvas scale from affecting the hierarchy-scaled ParticleSystem.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Obsolete("The autoScaling is now obsolete. Please use the autoScalingMode instead.", false)]
|
||||||
public bool autoScaling
|
public bool autoScaling
|
||||||
{
|
{
|
||||||
get { return m_AutoScaling; }
|
get { return m_AutoScalingMode != AutoScalingMode.None; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (m_AutoScaling == value) return;
|
autoScalingMode = value ? AutoScalingMode.Transform : AutoScalingMode.None;
|
||||||
m_AutoScaling = value;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Auto scaling mode.
|
||||||
|
/// Transform: Transform.lossyScale (=world scale) will be set to (1, 1, 1).
|
||||||
|
/// UIParticle: UIParticle.scale will be adjusted.
|
||||||
|
/// </summary>
|
||||||
|
public AutoScalingMode autoScalingMode
|
||||||
|
{
|
||||||
|
get { return m_AutoScalingMode; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (m_AutoScalingMode == value) return;
|
||||||
|
m_AutoScalingMode = value;
|
||||||
UpdateTracker();
|
UpdateTracker();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -234,6 +265,14 @@ namespace Coffee.UIExtensions
|
|||||||
set { m_Scale3D = value; }
|
set { m_Scale3D = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Particle effect scale.
|
||||||
|
/// </summary>
|
||||||
|
public Vector3 scale3DForCalc
|
||||||
|
{
|
||||||
|
get { return autoScalingMode == AutoScalingMode.UIParticle ? m_Scale3D.GetScaled(canvasScale) : m_Scale3D; }
|
||||||
|
}
|
||||||
|
|
||||||
public List<ParticleSystem> particles
|
public List<ParticleSystem> particles
|
||||||
{
|
{
|
||||||
get { return m_Particles; }
|
get { return m_Particles; }
|
||||||
@@ -267,6 +306,8 @@ namespace Coffee.UIExtensions
|
|||||||
|
|
||||||
public Vector3 parentScale { get; private set; }
|
public Vector3 parentScale { get; private set; }
|
||||||
|
|
||||||
|
public Vector3 canvasScale { get; private set; }
|
||||||
|
|
||||||
protected override void OnEnable()
|
protected override void OnEnable()
|
||||||
{
|
{
|
||||||
ResetGroupId();
|
ResetGroupId();
|
||||||
@@ -284,6 +325,13 @@ namespace Coffee.UIExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
base.OnEnable();
|
base.OnEnable();
|
||||||
|
|
||||||
|
// Reset scale for upgrade.
|
||||||
|
if (m_ResetScaleOnEnable)
|
||||||
|
{
|
||||||
|
m_ResetScaleOnEnable = false;
|
||||||
|
transform.localScale = Vector3.one;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -320,10 +368,22 @@ namespace Coffee.UIExtensions
|
|||||||
|
|
||||||
void ISerializationCallbackReceiver.OnAfterDeserialize()
|
void ISerializationCallbackReceiver.OnAfterDeserialize()
|
||||||
{
|
{
|
||||||
if (m_IgnoreCanvasScaler)
|
if (m_IgnoreCanvasScaler || m_AutoScaling)
|
||||||
{
|
{
|
||||||
m_IgnoreCanvasScaler = false;
|
m_IgnoreCanvasScaler = false;
|
||||||
m_AutoScaling = false;
|
m_AutoScaling = false;
|
||||||
|
m_AutoScalingMode = AutoScalingMode.Transform;
|
||||||
|
m_ResetScaleOnEnable = true;
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
EditorApplication.delayCall += () =>
|
||||||
|
{
|
||||||
|
if (!this || !gameObject || !transform) return;
|
||||||
|
transform.localScale = Vector3.one;
|
||||||
|
m_ResetScaleOnEnable = false;
|
||||||
|
EditorUtility.SetDirty(this);
|
||||||
|
};
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_AbsoluteMode)
|
if (m_AbsoluteMode)
|
||||||
@@ -471,8 +531,9 @@ namespace Coffee.UIExtensions
|
|||||||
|
|
||||||
internal void UpdateTransformScale()
|
internal void UpdateTransformScale()
|
||||||
{
|
{
|
||||||
|
canvasScale = canvas.rootCanvas.transform.localScale.Inverse();
|
||||||
parentScale = transform.parent.lossyScale;
|
parentScale = transform.parent.lossyScale;
|
||||||
if (!autoScaling) return;
|
if (autoScalingMode != AutoScalingMode.Transform) return;
|
||||||
|
|
||||||
var newScale = parentScale.Inverse();
|
var newScale = parentScale.Inverse();
|
||||||
if (transform.localScale != newScale)
|
if (transform.localScale != newScale)
|
||||||
@@ -586,7 +647,7 @@ namespace Coffee.UIExtensions
|
|||||||
// Create ortho-camera.
|
// Create ortho-camera.
|
||||||
if (!_orthoCamera)
|
if (!_orthoCamera)
|
||||||
{
|
{
|
||||||
var go = new GameObject("[generated] UIParticleOverlayCamera") { hideFlags = HideFlags.DontSave };
|
var go = new GameObject("[generated] UIParticleOverlayCamera") { hideFlags = HideFlags.DontSave | HideFlags.NotEditable };
|
||||||
go.SetActive(false);
|
go.SetActive(false);
|
||||||
go.transform.SetParent(transform, false);
|
go.transform.SetParent(transform, false);
|
||||||
_orthoCamera = go.AddComponent<Camera>();
|
_orthoCamera = go.AddComponent<Camera>();
|
||||||
@@ -606,7 +667,9 @@ namespace Coffee.UIExtensions
|
|||||||
|
|
||||||
private void UpdateTracker()
|
private void UpdateTracker()
|
||||||
{
|
{
|
||||||
if (!enabled || !autoScaling)
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
|
if (!enabled || !autoScaling || autoScalingMode != AutoScalingMode.Transform)
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
{
|
{
|
||||||
_tracker.Clear();
|
_tracker.Clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -182,21 +182,22 @@ namespace Coffee.UIExtensions
|
|||||||
if (isUI)
|
if (isUI)
|
||||||
{
|
{
|
||||||
var inverseScale = _uiParticle.parentScale.Inverse();
|
var inverseScale = _uiParticle.parentScale.Inverse();
|
||||||
dstPos = dstPos.GetScaled(inverseScale, _uiParticle.scale3D.Inverse());
|
var scale3d = _uiParticle.scale3DForCalc;
|
||||||
|
dstPos = dstPos.GetScaled(inverseScale, scale3d.Inverse());
|
||||||
|
|
||||||
// Relative mode
|
// Relative mode
|
||||||
if (_uiParticle.positionMode == UIParticle.PositionMode.Relative)
|
if (_uiParticle.positionMode == UIParticle.PositionMode.Relative)
|
||||||
{
|
{
|
||||||
var diff = _uiParticle.transform.position - psPos;
|
var diff = _uiParticle.transform.position - psPos;
|
||||||
diff.Scale(_uiParticle.scale3D - inverseScale);
|
diff.Scale(scale3d - inverseScale);
|
||||||
diff.Scale(_uiParticle.scale3D.Inverse());
|
diff.Scale(scale3d.Inverse());
|
||||||
dstPos += diff;
|
dstPos += diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
if (!Application.isPlaying && !isLocalSpace)
|
if (!Application.isPlaying && !isLocalSpace)
|
||||||
{
|
{
|
||||||
dstPos += psPos - psPos.GetScaled(inverseScale, _uiParticle.scale3D.Inverse());
|
dstPos += psPos - psPos.GetScaled(inverseScale, scale3d.Inverse());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Coffee.UIParticleExtensions;
|
using Coffee.UIParticleExtensions;
|
||||||
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Profiling;
|
using UnityEngine.Profiling;
|
||||||
using UnityEngine.Rendering;
|
using UnityEngine.Rendering;
|
||||||
@@ -14,10 +15,12 @@ namespace Coffee.UIExtensions
|
|||||||
[AddComponentMenu("")]
|
[AddComponentMenu("")]
|
||||||
internal class UIParticleRenderer : MaskableGraphic
|
internal class UIParticleRenderer : MaskableGraphic
|
||||||
{
|
{
|
||||||
|
private static readonly List<Component> s_Components = new List<Component>();
|
||||||
private static readonly CombineInstance[] s_CombineInstances = { new CombineInstance() };
|
private static readonly CombineInstance[] s_CombineInstances = { new CombineInstance() };
|
||||||
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 List<Color32> s_Colors = new List<Color32>();
|
||||||
private static readonly Vector3[] s_Corners = new Vector3[4];
|
private static readonly Vector3[] s_Corners = new Vector3[4];
|
||||||
private Material _currentMaterialForRendering;
|
private Material _currentMaterialForRendering;
|
||||||
private bool _delay;
|
private bool _delay;
|
||||||
@@ -31,6 +34,7 @@ namespace Coffee.UIExtensions
|
|||||||
private Vector3 _prevPsPos;
|
private Vector3 _prevPsPos;
|
||||||
private Vector3 _prevScale;
|
private Vector3 _prevScale;
|
||||||
private Vector2Int _prevScreenSize;
|
private Vector2Int _prevScreenSize;
|
||||||
|
private float _prevCanvasScale;
|
||||||
private bool _prewarm;
|
private bool _prewarm;
|
||||||
private ParticleSystemRenderer _renderer;
|
private ParticleSystemRenderer _renderer;
|
||||||
|
|
||||||
@@ -151,7 +155,7 @@ namespace Coffee.UIExtensions
|
|||||||
// Create renderer object.
|
// Create renderer object.
|
||||||
var go = new GameObject("[generated] UIParticleRenderer", typeof(UIParticleRenderer))
|
var go = new GameObject("[generated] UIParticleRenderer", typeof(UIParticleRenderer))
|
||||||
{
|
{
|
||||||
hideFlags = HideFlags.DontSave,
|
hideFlags = HideFlags.DontSave | HideFlags.NotEditable,
|
||||||
layer = parent.gameObject.layer
|
layer = parent.gameObject.layer
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -197,7 +201,12 @@ namespace Coffee.UIExtensions
|
|||||||
|
|
||||||
//
|
//
|
||||||
var id = _parent.m_AnimatableProperties.Length == 0 ? 0 : GetInstanceID();
|
var id = _parent.m_AnimatableProperties.Length == 0 ? 0 : GetInstanceID();
|
||||||
modifiedMaterial = ModifiedMaterial.Add(modifiedMaterial, texture, id);
|
#if UNITY_EDITOR
|
||||||
|
var props = EditorJsonUtility.ToJson(modifiedMaterial).GetHashCode();
|
||||||
|
#else
|
||||||
|
var props = 0;
|
||||||
|
#endif
|
||||||
|
modifiedMaterial = ModifiedMaterial.Add(modifiedMaterial, texture, id, props);
|
||||||
ModifiedMaterial.Remove(_modifiedMaterial);
|
ModifiedMaterial.Remove(_modifiedMaterial);
|
||||||
_modifiedMaterial = modifiedMaterial;
|
_modifiedMaterial = modifiedMaterial;
|
||||||
|
|
||||||
@@ -245,6 +254,7 @@ namespace Coffee.UIExtensions
|
|||||||
_prevScale = GetWorldScale();
|
_prevScale = GetWorldScale();
|
||||||
_prevPsPos = _particleSystem.transform.position;
|
_prevPsPos = _particleSystem.transform.position;
|
||||||
_prevScreenSize = new Vector2Int(Screen.width, Screen.height);
|
_prevScreenSize = new Vector2Int(Screen.width, Screen.height);
|
||||||
|
_prevCanvasScale = canvas ? canvas.scaleFactor : 1f;
|
||||||
_delay = true;
|
_delay = true;
|
||||||
_prevParticleCount = 0;
|
_prevParticleCount = 0;
|
||||||
|
|
||||||
@@ -260,7 +270,7 @@ namespace Coffee.UIExtensions
|
|||||||
!isActiveAndEnabled || !_particleSystem || !_parent
|
!isActiveAndEnabled || !_particleSystem || !_parent
|
||||||
|| !canvasRenderer || !canvas || !bakeCamera
|
|| !canvasRenderer || !canvas || !bakeCamera
|
||||||
|| _parent.meshSharing == UIParticle.MeshSharing.Replica
|
|| _parent.meshSharing == UIParticle.MeshSharing.Replica
|
||||||
|| !transform.lossyScale.GetScaled(_parent.scale3D).IsVisible() // Scale is not visible.
|
|| !transform.lossyScale.GetScaled(_parent.scale3DForCalc).IsVisible() // Scale is not visible.
|
||||||
|| (!_particleSystem.IsAlive() && !_particleSystem.isPlaying) // No particle.
|
|| (!_particleSystem.IsAlive() && !_particleSystem.isPlaying) // No particle.
|
||||||
|| (_isTrail && !_particleSystem.trails.enabled) // Trail, but it is not enabled.
|
|| (_isTrail && !_particleSystem.trails.enabled) // Trail, but it is not enabled.
|
||||||
#if UNITY_2018_3_OR_NEWER
|
#if UNITY_2018_3_OR_NEWER
|
||||||
@@ -380,6 +390,34 @@ namespace Coffee.UIExtensions
|
|||||||
bounds.extents = extents;
|
bounds.extents = extents;
|
||||||
workerMesh.bounds = bounds;
|
workerMesh.bounds = bounds;
|
||||||
_lastBounds = bounds;
|
_lastBounds = bounds;
|
||||||
|
|
||||||
|
// Convert linear color to gamma color.
|
||||||
|
if (QualitySettings.activeColorSpace == ColorSpace.Linear)
|
||||||
|
{
|
||||||
|
Profiler.BeginSample("[UIParticleRenderer] Convert Linear to Gamma");
|
||||||
|
workerMesh.GetColors(s_Colors);
|
||||||
|
var count_c = s_Colors.Count;
|
||||||
|
for (var i = 0; i < count_c; i++)
|
||||||
|
{
|
||||||
|
var c = s_Colors[i];
|
||||||
|
c.r = c.r.LinearToGamma();
|
||||||
|
c.g = c.g.LinearToGamma();
|
||||||
|
c.b = c.b.LinearToGamma();
|
||||||
|
s_Colors[i] = c;
|
||||||
|
}
|
||||||
|
workerMesh.SetColors(s_Colors);
|
||||||
|
Profiler.EndSample();
|
||||||
|
}
|
||||||
|
|
||||||
|
GetComponents(typeof(IMeshModifier), s_Components);
|
||||||
|
for (var i = 0; i < s_Components.Count; i++)
|
||||||
|
{
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
|
((IMeshModifier)s_Components[i]).ModifyMesh(workerMesh);
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
|
}
|
||||||
|
|
||||||
|
s_Components.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
Profiler.EndSample();
|
Profiler.EndSample();
|
||||||
@@ -411,8 +449,19 @@ namespace Coffee.UIExtensions
|
|||||||
|
|
||||||
// Update animatable material properties.
|
// Update animatable material properties.
|
||||||
Profiler.BeginSample("[UIParticleRenderer] Update Animatable Material Properties");
|
Profiler.BeginSample("[UIParticleRenderer] Update Animatable Material Properties");
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
if (_modifiedMaterial != material)
|
||||||
|
{
|
||||||
|
_renderer.GetSharedMaterials(s_Materials);
|
||||||
|
material = s_Materials[_isTrail ? 1 : 0];
|
||||||
|
s_Materials.Clear();
|
||||||
|
SetMaterialDirty();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
UpdateMaterialProperties();
|
UpdateMaterialProperties();
|
||||||
if (!_parent.useMeshSharing)
|
if (_parent.useMeshSharing)
|
||||||
{
|
{
|
||||||
if (!_currentMaterialForRendering)
|
if (!_currentMaterialForRendering)
|
||||||
{
|
{
|
||||||
@@ -462,7 +511,7 @@ namespace Coffee.UIExtensions
|
|||||||
private Vector3 GetWorldScale()
|
private Vector3 GetWorldScale()
|
||||||
{
|
{
|
||||||
Profiler.BeginSample("[UIParticleRenderer] GetWorldScale");
|
Profiler.BeginSample("[UIParticleRenderer] GetWorldScale");
|
||||||
var scale = _parent.scale3D.GetScaled(_parent.parentScale);
|
var scale = _parent.scale3DForCalc.GetScaled(_parent.parentScale);
|
||||||
Profiler.EndSample();
|
Profiler.EndSample();
|
||||||
return scale;
|
return scale;
|
||||||
}
|
}
|
||||||
@@ -515,7 +564,8 @@ namespace Coffee.UIExtensions
|
|||||||
{
|
{
|
||||||
var screenSize = new Vector2Int(Screen.width, Screen.height);
|
var screenSize = new Vector2Int(Screen.width, Screen.height);
|
||||||
var isWorldSpace = _particleSystem.IsWorldSpace();
|
var isWorldSpace = _particleSystem.IsWorldSpace();
|
||||||
var resolutionChanged = _prevScreenSize != screenSize || _prevScale != scale;
|
var canvasScale = _parent.canvas ? _parent.canvas.scaleFactor : 1f;
|
||||||
|
var resolutionChanged = _prevScreenSize != screenSize || _prevCanvasScale != canvasScale;
|
||||||
if (resolutionChanged && isWorldSpace)
|
if (resolutionChanged && isWorldSpace)
|
||||||
{
|
{
|
||||||
// Update particle array size and get particles.
|
// Update particle array size and get particles.
|
||||||
@@ -544,6 +594,7 @@ namespace Coffee.UIExtensions
|
|||||||
_prevPsPos = psPos;
|
_prevPsPos = psPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_prevCanvasScale = canvas ? canvas.scaleFactor : 1f;
|
||||||
_prevScreenSize = screenSize;
|
_prevScreenSize = screenSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,25 @@ using Object = UnityEngine.Object;
|
|||||||
|
|
||||||
namespace Coffee.UIParticleExtensions
|
namespace Coffee.UIParticleExtensions
|
||||||
{
|
{
|
||||||
|
public static class Color32Extensions
|
||||||
|
{
|
||||||
|
private static byte[] s_LinearToGammaLut;
|
||||||
|
|
||||||
|
public static byte LinearToGamma(this byte self)
|
||||||
|
{
|
||||||
|
if (s_LinearToGammaLut == null)
|
||||||
|
{
|
||||||
|
s_LinearToGammaLut = new byte[256];
|
||||||
|
for (var i = 0; i < 256; i++)
|
||||||
|
{
|
||||||
|
s_LinearToGammaLut[i] = (byte)(Mathf.LinearToGammaSpace(i / 255f) * 255f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return s_LinearToGammaLut[self];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class Vector3Extensions
|
public static class Vector3Extensions
|
||||||
{
|
{
|
||||||
public static Vector3 Inverse(this Vector3 self)
|
public static Vector3 Inverse(this Vector3 self)
|
||||||
|
|||||||
@@ -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.2.2",
|
"version": "4.5.1",
|
||||||
"unity": "2018.2",
|
"unity": "2018.2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
Reference in New Issue
Block a user