Browse Source

Fixed child sprites not fading in some cases

master
chrisgregan 11 years ago
parent
commit
2064c853be
  1. 24
      Assets/Fungus/Scripts/SpriteFader.cs
  2. BIN
      Assets/FungusExample/Scenes/Example.unity

24
Assets/Fungus/Scripts/SpriteFader.cs

@ -30,6 +30,18 @@ namespace Fungus
return;
}
// Fade child sprite renderers
SpriteRenderer[] children = spriteRenderer.gameObject.GetComponentsInChildren<SpriteRenderer>();
foreach (SpriteRenderer child in children)
{
if (child == spriteRenderer)
{
continue;
}
FadeSprite(child, targetColor, duration, slideOffset);
}
// Destroy any existing fader component
SpriteFader oldSpriteFader = spriteRenderer.GetComponent<SpriteFader>();
{
@ -50,18 +62,6 @@ namespace Fungus
spriteFader.endColor = targetColor;
spriteFader.endPosition = spriteRenderer.transform.position;
spriteFader.slideOffset = slideOffset;
// Fade child sprite renderers
SpriteRenderer[] children = spriteRenderer.gameObject.GetComponentsInChildren<SpriteRenderer>();
foreach (SpriteRenderer child in children)
{
if (child == spriteRenderer)
{
continue;
}
FadeSprite(child, targetColor, duration, slideOffset);
}
}
void Start()

BIN
Assets/FungusExample/Scenes/Example.unity

Binary file not shown.
Loading…
Cancel
Save