fix: support sub emitter with 'PlayOnAwake'
parent
3bb5241275
commit
d5ce78ae5a
|
@ -1,6 +1,7 @@
|
|||
#if UNITY_2019_3_11 || UNITY_2019_3_12 || UNITY_2019_3_13 || UNITY_2019_3_14 || UNITY_2019_3_15 || UNITY_2019_4_OR_NEWER
|
||||
#define SERIALIZE_FIELD_MASKABLE
|
||||
#endif
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Coffee.UIParticleExtensions;
|
||||
|
@ -60,6 +61,7 @@ namespace Coffee.UIExtensions
|
|||
private static readonly List<Material> s_PrevMaskMaterials = new List<Material>();
|
||||
private static readonly List<Material> s_PrevModifiedMaterials = new List<Material>();
|
||||
private static readonly List<Component> s_Components = new List<Component>();
|
||||
private static readonly List<ParticleSystem> s_ParticleSystems = new List<ParticleSystem>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
@ -407,6 +409,22 @@ namespace Coffee.UIExtensions
|
|||
InitializeIfNeeded();
|
||||
}
|
||||
|
||||
private new IEnumerator Start()
|
||||
{
|
||||
// #148: Particle Sub Emitter not showing when start game
|
||||
var hasPlayingSubEmitter = particles.AnyFast(ps =>
|
||||
{
|
||||
ps.GetComponentsInChildren(false, s_ParticleSystems);
|
||||
return s_ParticleSystems.AnyFast(p => p.isPlaying && p.subEmitters.enabled);
|
||||
});
|
||||
s_ParticleSystems.Clear();
|
||||
if (!hasPlayingSubEmitter) yield break;
|
||||
|
||||
Stop();
|
||||
yield return null;
|
||||
Play();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function is called when the behaviour becomes disabled.
|
||||
/// </summary>
|
||||
|
|
|
@ -65,6 +65,16 @@ namespace Coffee.UIParticleExtensions
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool AnyFast<T>(this List<T> self, Predicate<T> predicate) where T : Object
|
||||
{
|
||||
for (var i = 0; i < self.Count; ++i)
|
||||
{
|
||||
if (self[i] && predicate(self[i])) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
internal static class MeshExtensions
|
||||
|
|
Loading…
Reference in New Issue