Hi,
I have the following code
using UnityEngine;
using System.Collections;
public class Splash : MonoBehaviour {
public Texture2D[] tex; // Holds all the splashscreens
public float faderSpeed;// sets the fading speed
private float fader; // holds the actual fade value
private Texture2D splash; // holds the currently displayed splash.
void Awake()
{
Start();
OnGUI();
}
IEnumerator Start()
{
for(int i=0; i<tex.Length;i++)
{
yield return StartCoroutine(FadeSplash(tex[i]));
}
splash = null;
LoadLevel();
}
IEnumerator FadeSplash(Texture2D pSplash)
{
// Set to initial state and assign image
fader = 0;
splash = pSplash;
// Fade in
while(fader<1)
{
yield return null;
fader += Time.deltaTime * faderSpeed;
}
fader = 1;
// Keep displayed for # seconds
yield return new WaitForSeconds(1.5f);
// Fade out
while(fader>0)
{
yield return null;
fader -= Time.deltaTime * faderSpeed;
}
fader = 0;
}
void OnGUI()
{
if(splash!=null)
{
GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, fader);
GUI.DrawTexture(new Rect(1,1,1000, 1000),splash);
GUI.color = new Color(0,0,0,1);
}
}
void LoadLevel ()
{
Application.LoadLevel(1);
}
}
I can’t seem to view this screen once it is built. Works fine in the editor.
Also, I would the images rescaled depending on resolution. I have tried several codes and none of them worked for me. Im not a very good coder, so thats probably why.
Firstly, why doesn’t the scene work? Its all set up in build settings properly. After the Unity splash, it goes straight into my main menu rather than showing my splash.