I’m expecting this to decrease the alpha of my GUI smoothly from 1f to 0f, however it simply flutters around 0.6f and drops the framerate to 20fps! I’ve decreased the smoothTime to 0.1f to simply try and spur the process into action, but eventually this will be changed to 1 second. I don’t understand what’s going on especially as I’ve spent hours looking at this and can’t seem to find fault in my code! I blame the useless Unity docs… unless of course I’m being an idiot
Here’s the code:
void Start () {
splash = Resources.Load<Texture2D> ("Splash");
initTime = Time.time;
smoothVelocity = 0f;
}
void OnGUI () {
if (initTime + 4f < Time.time) {
Color newColor = GUI.color;
newColor.a = Mathf.SmoothDamp(newColor.a, 0f, ref smoothVelocity, 0.1f);
GUI.color = newColor;
}
//Show splash screen
GUI.DrawTexture (new Rect (0f, 0f, Screen.width, Screen.height), splash, ScaleMode.ScaleToFit);
}