3.0.0-preview.30

# [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](8bd9b621b9))

### Features

* add API to bind ParticleSystem object ([a77bbd3](a77bbd3a9a))
This commit is contained in:
semantic-release-bot
2020-09-02 05:15:30 +00:00
parent c8ecd56e76
commit b12b82c172
4 changed files with 54 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using UnityEngine;
using UnityEngine.Rendering;
@@ -123,6 +124,43 @@ namespace Coffee.UIExtensions
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);
@@ -321,7 +359,7 @@ namespace Coffee.UIExtensions
return;
}
if (!this || 0 < particles.Count) return;
if (!this || particles.Any(x => x)) return;
m_IgnoreCanvasScaler = true;