Forum rules - please read before posting.

Is there a way to fade a sprite partially via action script?

I just want to know if there is a way to fade a sprite to, for instance, 80% opacity using actions, or has anybody made a custom action that does this?

Thank you and God bless!


  • edited May 21

    You shouldn't need a custom Action for this - for such situations, you can create an animation to handle this.

    Attach an Animator component to your sprite and assign a new Animator Controller. Give it a blank default animation, and then a new animation that sets the sprite's colour to one with an alpha value of 0.8.

    You can then use the Object: Animate Action to control this animation's playback - either by calling the animation clip by name, or changing an Animator parameter that causes a transition to it. You can also optionally attach the Remember Animator component to it to record this playback state in your save game files.

    This technique can actually be used to control any Inspector property that can be controlled in animation clips - things like the "Sprite Fader" component are more of a convenience than a necessity.

  • Thank you again for your help. I'm sure everything you said is true, but I can never, ever get animations to work. On sprites, or prefabs, or Unity GUI's Raw Images, or Old Moat's Animated gif objects, even after taking Unity Premiere's animation tutorial.

    I'm probably one tiny oversight away from using those things, but who knows how long it'll take me to figure out what that is, and my sister thinks she's got a work-around on the asset side, so I should probably take it.

    I'm looking forward to sharing what I make! :-)

  • If you're having trouble with animation in general, you're probably best off posting on the Unity forums. But if you'd like to share screens of what you've tried so far (regarding this particular issue), I can try to see what the problem might be.

  • So, I deleted all the animations and their references, thinking that there was no point in trying to fix them. Then I got your message offering to help, and I decided to try and recreate my failed attempt to use the animations. The attempt failed.
    They work perfectly, and my sister is thrilled.

    I'm so relieved. And embarrassed.
    I'm also happy you won't be spending a Sunday morning studying my screen caps. ^_^

    Stay safe and God bless!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.
Do NOT follow this link or you will be banned from the site!