Fade transition on UI Image

Help, support and information for our Beautiful Transitions Unity Asset
Post Reply
snouto
Posts: 4
Joined: Thu Aug 17, 2017 5:02 am

Fade transition on UI Image

Post by snouto » Thu Aug 17, 2017 5:11 am

Hi

I'm trying unsuccessfully to get a GUI image to fade from 1 to 0 when my game first starts (sort of like a splash screen). I've tried using the TransitionManager with a fade component, as well as purely from script, but neither approach appears to make the image fade out.

When using the script approach I can see the OnComplete message appearing in the console so clearly the script thinks the transition is working - it just isn't. Am I missing something obvious?

Code: Select all

void Start(){

        var transition = new Fade(splashFadeObject,1,0,2,0.5f,onComplete: OnSplashAlphaComplete);
        transition.Start();

    }

    void OnSplashAlphaComplete()
    {
        Debug.Log("Complete with parameter: ");
    }
    

mahewitt
Site Admin
Posts: 252
Joined: Thu May 05, 2016 8:06 pm

Re: Fade transition on UI Image

Post by mahewitt » Thu Aug 17, 2017 5:27 am

Hi,

The code sample looks correct, and you should also be able to do this by adding a fade component with autorun and init for transitionin set to true.

The fact the callback is triggered seems to show something is happening... Are you using an Image or RawImage? I see only Image is supported, but I can easily add support or you can add a CanvasGroup component also?

If that doesn't help then if you have a small sample that you can email me (address in asset readme) with just the scene, image and above script then I can run some further tests.

Regards,
Mark

snouto
Posts: 4
Joined: Thu Aug 17, 2017 5:02 am

Re: Fade transition on UI Image

Post by snouto » Thu Aug 17, 2017 5:51 am

Hi mark, thanks for the quick reply.

I'm using a normal Image (I did use raw image, but that didn't work either). The image remains on screen and never fades out. I'm in the middle of finishing off a prototype so I don't really have time to make a test scene right now, but I will if time permits.

Cheers

[edit]

Maybe you can see something strange in my image setup?

Image

snouto
Posts: 4
Joined: Thu Aug 17, 2017 5:02 am

Re: Fade transition on UI Image

Post by snouto » Thu Aug 17, 2017 6:30 am

Ok so I just tried again using the fade component but this time I chose it from the Add Component menu, and picked the Transition Fade script. It worked. So clearly there must have been something wrong with how I went about doing this previously using components.

But here's the strange thing - with my script disabled, and auto run enabled on the transition, it still doesn't fade out. Only if I have my code enabled will it actually fade out (and it doesn't seem to matter if auto-run is enabled or not).

mahewitt
Site Admin
Posts: 252
Joined: Thu May 05, 2016 8:06 pm

Re: Fade transition on UI Image

Post by mahewitt » Fri Aug 18, 2017 5:40 am

Hi. At the moment the transition out (fade out) doesn't run automatically following the transition in (this as a selectable option is coming). You can however either trigger this through code, or under Transition In Config -> Events add an On Transition Complete event, target this to the same gameobject containing the transition component and then find and select the transition's TransitionOut() method.

Let me know if that does the trick...

snouto
Posts: 4
Joined: Thu Aug 17, 2017 5:02 am

Re: Fade transition on UI Image

Post by snouto » Mon Aug 21, 2017 3:39 am

Thanks, I tried that and it seemed to work so I was able to remove my code in favour of the event based system.

I'm still having a lot of trouble loading from scene 3 back to scene 1, and it appears to be an issue that SceneManager.loadScene also has. No idea why, but it appears as though scene 1 loads in to the hierarchy but is never initialised. I never see Awake or Start debug statements appear and the scene never starts. It just sort of sits there, loaded, but not running. This is on desktop as well as device. Very strange.

Thanks for your help.

Post Reply