3.0.0-preview.24

# [3.0.0-preview.24](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.23...v3.0.0-preview.24) (2020-09-01)

### Bug Fixes

* hide camera for baking ([30b4703](30b4703e2a))
* In ignore canvas scaler mode, Transform.localScale is zero ([cc71f2b](cc71f2bdac)), closes [#89](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/89)
* In prefab mode, an error occurs ([a222f37](a222f3710b)), closes [#88](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/88)

### Features

* remove menu in inspector ([e7f8f51](e7f8f51212))
This commit is contained in:
semantic-release-bot
2020-09-01 04:50:54 +00:00
parent 0eb76a6432
commit 9071798353
6 changed files with 108 additions and 33 deletions

View File

@@ -20,7 +20,7 @@ namespace Coffee.UIExtensions
, ISerializationCallbackReceiver
#endif
{
[HideInInspector] [SerializeField] bool m_IsTrail = false;
[HideInInspector] [SerializeField] internal bool m_IsTrail = false;
[Tooltip("Ignore canvas scaler")] [SerializeField] [FormerlySerializedAs("m_IgnoreParent")]
bool m_IgnoreCanvasScaler = true;
@@ -34,6 +34,7 @@ namespace Coffee.UIExtensions
[Tooltip("Particles")] [SerializeField]
private List<ParticleSystem> m_Particles = new List<ParticleSystem>();
private bool _shouldBeRemoved;
private DrivenRectTransformTracker _tracker;
private Mesh _bakedMesh;
private readonly List<Material> _modifiedMaterials = new List<Material>();
@@ -56,7 +57,14 @@ namespace Coffee.UIExtensions
public bool ignoreCanvasScaler
{
get { return m_IgnoreCanvasScaler; }
set { m_IgnoreCanvasScaler = value; }
set
{
// if (m_IgnoreCanvasScaler == value) return;
m_IgnoreCanvasScaler = value;
_tracker.Clear();
if (isActiveAndEnabled && m_IgnoreCanvasScaler)
_tracker.Add(this, rectTransform, DrivenTransformProperties.Scale);
}
}
/// <summary>
@@ -244,20 +252,24 @@ namespace Coffee.UIExtensions
/// </summary>
protected override void OnEnable()
{
InitializeIfNeeded();
_cachedPosition = transform.localPosition;
_activeMeshIndices = 0;
UIParticleUpdater.Register(this);
particles.Exec(p => p.GetComponent<ParticleSystemRenderer>().enabled = false);
_tracker.Add(this, rectTransform, DrivenTransformProperties.Scale);
if (isActiveAndEnabled && m_IgnoreCanvasScaler)
{
_tracker.Add(this, rectTransform, DrivenTransformProperties.Scale);
}
// Create objects.
_bakedMesh = new Mesh();
_bakedMesh.MarkDynamic();
base.OnEnable();
InitializeIfNeeded();
}
/// <summary>
@@ -266,7 +278,8 @@ namespace Coffee.UIExtensions
protected override void OnDisable()
{
UIParticleUpdater.Unregister(this);
particles.Exec(p => p.GetComponent<ParticleSystemRenderer>().enabled = true);
if (!_shouldBeRemoved)
particles.Exec(p => p.GetComponent<ParticleSystemRenderer>().enabled = true);
_tracker.Clear();
// Destroy object.
@@ -299,28 +312,25 @@ namespace Coffee.UIExtensions
private void InitializeIfNeeded()
{
if (enabled && m_IsTrail)
{
UnityEngine.Debug.LogWarningFormat(this, "[UIParticle] The UIParticle component should be removed: {0}\nReason: UIParticle for trails is no longer needed.", name);
gameObject.hideFlags = HideFlags.None;
_shouldBeRemoved = true;
enabled = false;
return;
}
else if (enabled && transform.parent && transform.parent.GetComponentInParent<UIParticle>())
{
UnityEngine.Debug.LogWarningFormat(this, "[UIParticle] The UIParticle component should be removed: {0}\nReason: The parent UIParticle exists.", name);
gameObject.hideFlags = HideFlags.None;
_shouldBeRemoved = true;
enabled = false;
return;
}
if (!this || 0 < particles.Count) return;
if (m_IsTrail)
{
UnityEngine.Debug.LogWarningFormat("[UIParticle] Remove this UIParticle: {0}\nReason: UIParticle for trails is no longer needed.", name);
if (Application.isPlaying)
Destroy(gameObject);
else
DestroyImmediate(gameObject);
return;
}
if (transform.parent && transform.parent.GetComponentInParent<UIParticle>())
{
UnityEngine.Debug.LogWarningFormat("[UIParticle] Remove this UIParticle: {0}\nReason: The parent UIParticle exists.", name);
if (Application.isPlaying)
Destroy(this);
else
DestroyImmediate(this);
return;
}
m_IgnoreCanvasScaler = true;
// refresh.