Skip to content

Commit

Permalink
3.0.0-preview.30
Browse files Browse the repository at this point in the history
# [3.0.0-preview.30](mob-sakai/ParticleEffectForUGUI@v3.0.0-preview.29...v3.0.0-preview.30) (2020-09-02)

### Bug Fixes

* ignore missing object on initialize ([8bd9b62](mob-sakai/ParticleEffectForUGUI@8bd9b62))

### Features

* add API to bind ParticleSystem object ([a77bbd3](mob-sakai/ParticleEffectForUGUI@a77bbd3))
  • Loading branch information
LionelPerrault committed Sep 2, 2020
1 parent bb7ab9e commit d77c502
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 2 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# [3.0.0-preview.30](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.29...v3.0.0-preview.30) (2020-09-02)


### Bug Fixes

* ignore missing object on initialize ([8bd9b62](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/8bd9b621b9efcd242c410405d066494a1d53f9a3))


### Features

* add API to bind ParticleSystem object ([a77bbd3](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/a77bbd3a9a65d5fd1198bd8e580982ca8e07fca8))

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


Expand Down
40 changes: 39 additions & 1 deletion Scripts/UIParticle.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using UnityEngine;
using UnityEngine.Rendering;
Expand Down Expand Up @@ -123,6 +124,43 @@ public void Stop()
particles.Exec(p => p.Stop());
}

public void SetParticleSystemInstance(GameObject instance)
{
SetParticleSystemInstance(instance, true);
}

public void SetParticleSystemInstance(GameObject instance, bool destroy)
{
if (!instance) return;

foreach (Transform child in transform)
{
var go = child.gameObject;
go.SetActive(false);
if (!destroy) continue;

#if UNITY_EDITOR
if (!Application.isPlaying)
DestroyImmediate(go);
else
#endif
Destroy(go);
}

var tr = instance.transform;
tr.SetParent(transform, false);
tr.localPosition = Vector3.zero;

RefreshParticles();
}

public void SetParticleSystemPrefab(GameObject prefab)
{
if (!prefab) return;

SetParticleSystemInstance(Instantiate(prefab.gameObject), true);
}

public void RefreshParticles()
{
GetComponentsInChildren(particles);
Expand Down Expand Up @@ -321,7 +359,7 @@ private void InitializeIfNeeded()
return;
}

if (!this || 0 < particles.Count) return;
if (!this || particles.Any(x => x)) return;

m_IgnoreCanvasScaler = true;

Expand Down
2 changes: 2 additions & 0 deletions Scripts/UIParticleUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ private static void InitializeOnLoad()

private static void Refresh()
{
Profiler.BeginSample("[UIParticle] Refresh");
for (var i = 0; i < s_ActiveParticles.Count; i++)
{
try
Expand All @@ -51,6 +52,7 @@ private static void Refresh()
Debug.LogException(e);
}
}
Profiler.EndSample();
}

private static void Refresh(UIParticle particle)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.29",
"version": "3.0.0-preview.30",
"unity": "2018.2",
"license": "MIT",
"repository": {
Expand Down

0 comments on commit d77c502

Please sign in to comment.