Skip to content

Commit

Permalink
fix #16; Using prefab view will cause a lot of errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mob-sakai committed Dec 12, 2018
1 parent 8900798 commit f35d8fa
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions Assets/Coffee/UIExtensions/UIParticle/UIParticle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class UIParticle : MaskableGraphic
static readonly int s_IdMainTex = Shader.PropertyToID ("_MainTex");
static readonly List<Vector3> s_Vertices = new List<Vector3> ();
static readonly List<UIParticle> s_TempRelatables = new List<UIParticle> ();
static readonly List<UIParticle> s_ActiveSoftMasks = new List<UIParticle> ();
static readonly List<UIParticle> s_ActiveParticles = new List<UIParticle> ();


//################################
Expand Down Expand Up @@ -109,11 +109,11 @@ public override Material GetModifiedMaterial (Material baseMaterial)
protected override void OnEnable ()
{
// Register.
if (s_ActiveSoftMasks.Count == 0)
if (s_ActiveParticles.Count == 0)
{
Canvas.willRenderCanvases += UpdateMeshes;
}
s_ActiveSoftMasks.Add (this);
s_ActiveParticles.Add (this);

// Reset the parent-child relation.
GetComponentsInChildren<UIParticle> (false, s_TempRelatables);
Expand All @@ -137,8 +137,8 @@ protected override void OnEnable ()
protected override void OnDisable ()
{
// Unregister.
s_ActiveSoftMasks.Remove (this);
if (s_ActiveSoftMasks.Count == 0)
s_ActiveParticles.Remove (this);
if (s_ActiveParticles.Count == 0)
{
Canvas.willRenderCanvases -= UpdateMeshes;
}
Expand Down Expand Up @@ -208,9 +208,12 @@ protected override void OnValidate ()

static void UpdateMeshes ()
{
foreach (var uip in s_ActiveSoftMasks)
foreach (var uip in s_ActiveParticles)
{
uip.UpdateMesh ();
if(uip)
{
uip.UpdateMesh ();
}
}
}

Expand Down

0 comments on commit f35d8fa

Please sign in to comment.