- Home /
Can some one help me with splash screen?
I apologize for any inconvenience before hand because I am sure this question has been asked before, I just cannot find the answer. I am new to unity and been at it for about 2 months now. With help from tutorials I have gotten "use" to the engine itself. But my problem came from C# programming for I have no experience at all. 1st Scene in any video game is Logo Scene followed by a Title screen, so I made them both into scenes. 1.Logo and 2.StartScreen, now to connect them. I was thinking maybe a C# script connected to the main camera in the Logo Scene BUT I cannot connect. It reads:
" Can't add component 'SplashScreenDelay' because it doesn't exist. Check to see if the file name and class name match. "
Now in the end I've tried I think 3 different scripts I've found online or in videos and all are the same result. I'm trying to get it to stay on the Logo Scene for 5sec then change to the Title Scene. This is the most recent code I've used:
using UnityEngine;
using System.Collections;
public class SplashScreenDelay : MonoBehaviour {
public float delayTime = 5;
IEnumerator start() {
yield return new WaitForSeconds( delayTime );
Application.LoadLevel("2.StartScreen");
}
}
I've done a Clean and a Build in Mono and I have no errors for the script so I can't see the problem... Can any one please tell me what I am doing wrong?
Thx in advance for any assistance....
Answer by Landern · Dec 31, 2014 at 06:33 AM
With c# scripts your class name must match the file name.
Using your example above. If the class is called SplashScreenDelay Then the file in your assets must be SplashScreenDelay and the file on disk must be SplashScreenDelay.cs, this applies specifically when deriving/inheriting from MonoBehaviour.
That is what "Can't add component 'SplashScreenDelay' because it doesn't exist. Check to see if the file name and class name match." is literally telling you.
and if you expect unity to automagically call your start()
method then change it to Start()
... they are not the same thing.