So, on the game being first started/initialized/whatever the lingo is (Your press play or start the game up), I would like this script to initialize:
using UnityEngine;
using System.Collections;
public class Logofadein : MonoBehaviour {
public float fadeSpeed = 1f;
public bool fadeIn = true;
public SpriteRenderer text;
// Use this for initialization
// Invisible on Awake
void Awake()
{
text.color = new Color(1f, 1f, 1f, 0f);
}
// Update is called once per frame
void Update()
{
float Fade = 0f;
if (fadeIn)
{
text.color = new Color(1f, 1f, 1f, Fade = +.1f);
}
}
}
Now, what this I would like it to do is fade in a completely invisible object to a solid object: The game logo, for the main menu. I grabbed this script from the forums of someone asking the same thing.
The problem is that the sprite fades in by the amount, then stays at .1f. It doesn’t go fully solid like it’s supposed to. Now, what I noticed is that the update command is setting it back to 0, then adding .1 fade, then repeating, making it never fully fade in. At first I thought it was only doing it once, but instead its doing a never ending loop of resetting and moving up by .1f.
Now, what I am asking, is how do I fix this? I tried to move the “float fade=0f” outside the update but it gets a compile error. Do I need to add in a “Repeat until value = 1f, 1f, 1f, 1f” or would it just be redundant but effectively ending its purpose when it hits the full fade in?
How would I go about broadcasting an “Okay this is done” signal? I could not find specific documentation on this that I could understand. I want it to fade in, then broadcast this signal so I can fade in the “Play, options, and exit” buttons.
If you could send me any documentation on this that is easy to understand then I would greatly appriciate it, thank you in advance.