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))
pull/120/head
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

@ -1,3 +1,17 @@
# [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](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/30b4703e2a1746efc4b7db154354f80fd0593b98))
* In ignore canvas scaler mode, Transform.localScale is zero ([cc71f2b](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/cc71f2bdac1a61fd5e5fc85d0a69589e05a0f79d)), closes [#89](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/89)
* In prefab mode, an error occurs ([a222f37](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/a222f3710b530c7fc9fab10f25bd28d820ffebe2)), closes [#88](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/88)
### Features
* remove menu in inspector ([e7f8f51](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/e7f8f512122a01423de415b55e3190d62bda146a))
# [3.0.0-preview.23](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.22...v3.0.0-preview.23) (2020-08-31)

View File

@ -53,7 +53,6 @@ namespace Coffee.UIExtensions
// This camera object is just for internal use
gameObject.hideFlags = HideFlags.HideAndDontSave;
gameObject.hideFlags = HideFlags.DontSave;
var inst = gameObject.AddComponent<BakingCamera>();
inst._camera = gameObject.AddComponent<Camera>();

View File

@ -16,6 +16,9 @@ namespace Coffee.UIExtensions
//################################
private static readonly GUIContent s_ContentRenderingOrder = new GUIContent("Rendering Order");
private static readonly GUIContent s_ContentRefresh = new GUIContent("Refresh");
private static readonly GUIContent s_ContentFix = new GUIContent("Fix");
private static readonly List<UIParticle> s_TempParents = new List<UIParticle>();
private static readonly List<UIParticle> s_TempChildren = new List<UIParticle>();
private SerializedProperty _spScale;
private SerializedProperty _spIgnoreCanvasScaler;
@ -81,7 +84,17 @@ namespace Coffee.UIExtensions
serializedObject.Update();
// IgnoreCanvasScaler
EditorGUILayout.PropertyField(_spIgnoreCanvasScaler);
using (var ccs = new EditorGUI.ChangeCheckScope())
{
EditorGUILayout.PropertyField(_spIgnoreCanvasScaler);
if (ccs.changed)
{
foreach (UIParticle p in targets)
{
p.ignoreCanvasScaler = _spIgnoreCanvasScaler.boolValue;
}
}
}
// Scale
EditorGUILayout.PropertyField(_spScale);
@ -91,6 +104,8 @@ namespace Coffee.UIExtensions
_ro.DoLayoutList();
serializedObject.ApplyModifiedProperties();
// Does the shader support UI masks?
if (current.maskable && current.GetComponentInParent<Mask>())
{
@ -108,7 +123,46 @@ namespace Coffee.UIExtensions
}
}
serializedObject.ApplyModifiedProperties();
// Does the shader support UI masks?
if (FixButton(current.m_IsTrail,"This UIParticle component should be removed. The UIParticle for trails is no longer needed."))
{
DestroyUIParticle(current);
return;
}
current.GetComponentsInParent(true, s_TempParents);
if (FixButton(1 < s_TempParents.Count,"This UIParticle component should be removed. The parent UIParticle exists."))
{
DestroyUIParticle(current);
return;
}
current.GetComponentsInChildren(true, s_TempChildren);
if (FixButton(1 < s_TempChildren.Count,"The children UIParticle component should be removed."))
{
s_TempChildren.ForEach(child => DestroyUIParticle(child, true));
}
}
void DestroyUIParticle(UIParticle p, bool ignoreCurrent = false)
{
if (!p || ignoreCurrent && target == p) return;
var cr = p.canvasRenderer;
DestroyImmediate(p);
DestroyImmediate(cr);
}
bool FixButton(bool show, string text)
{
if (!show) return false;
using (new EditorGUILayout.HorizontalScope(GUILayout.ExpandWidth(true)))
{
EditorGUILayout.HelpBox(text, MessageType.Warning, true);
using (new EditorGUILayout.VerticalScope())
{
return GUILayout.Button(s_ContentFix, GUILayout.Width(30));
}
}
}
}
}

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.

View File

@ -57,7 +57,7 @@ namespace Coffee.UIExtensions
private static void Refresh(UIParticle particle)
{
if (!particle) return;
if (!particle || !particle.canvas || !particle.canvasRenderer) return;
Profiler.BeginSample("Modify scale");
ModifyScale(particle);
@ -131,8 +131,6 @@ namespace Coffee.UIExtensions
MeshHelper.Clear();
particle.bakedMesh.Clear(false);
// if (!particle.isValid) return;
// Get camera for baking mesh.
var camera = BakingCamera.GetCamera(particle.canvas);
var root = particle.transform;

View File

@ -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.0.0-preview.23",
"version": "3.0.0-preview.24",
"unity": "2018.2",
"license": "MIT",
"repository": {