diff --git a/Assets/Fungus/Scripts/SpriteFader.cs b/Assets/Fungus/Scripts/SpriteFader.cs index 20f867f7..f3864b24 100644 --- a/Assets/Fungus/Scripts/SpriteFader.cs +++ b/Assets/Fungus/Scripts/SpriteFader.cs @@ -30,6 +30,18 @@ namespace Fungus return; } + // Fade child sprite renderers + SpriteRenderer[] children = spriteRenderer.gameObject.GetComponentsInChildren(); + foreach (SpriteRenderer child in children) + { + if (child == spriteRenderer) + { + continue; + } + + FadeSprite(child, targetColor, duration, slideOffset); + } + // Destroy any existing fader component SpriteFader oldSpriteFader = spriteRenderer.GetComponent(); { @@ -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(); - foreach (SpriteRenderer child in children) - { - if (child == spriteRenderer) - { - continue; - } - - FadeSprite(child, targetColor, duration, slideOffset); - } } void Start() diff --git a/Assets/FungusExample/Scenes/Example.unity b/Assets/FungusExample/Scenes/Example.unity index 90db1f79..caec8d76 100644 Binary files a/Assets/FungusExample/Scenes/Example.unity and b/Assets/FungusExample/Scenes/Example.unity differ