Alternative Code for Fade In

I used the method CrossFadeAplha() of the Image class to achieve the wanted result. Is there any drawback to the way I did it? At first glance, it seems much simpler than what Ben showed in the video. I appreciate any input on this! Here is my code:

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class Fader : MonoBehaviour {

    public float fadeInTime;

    private Image panel;

	// Use this for initialization
	void Start () {
        panel = GetComponent<Image>();
        panel.CrossFadeAlpha(0, fadeInTime, false);

this is the way that I approached it as well when I paused for the challenge, the big difference that I saw was that at the end of the animation to go to full alpha it isn’t as smooth as the code that we learn in the course as you can see the panel kind of flash at the end once you disable the panel so that you can click the options in the menu.

but they are both right just your preference I guess.

Privacy & Terms