- Home /
after upgrading to Unity4.2 all levels work in editor, but not in Ouya correctly anymore?
Problem:
I have a project I'm developing for the Ouya, and it was loading fine in Unity 3.5, and exporting to the Ouya without any issues and playing fine.
I recently upgraded to Unity 4.2, and everything works in the Unity editor just fine, but my splash screen just goes black and never shows the image or loads the title screen like it used to.
I then took out the splash screen from the build settings and got my main menu to load directly, as the first scene, which switches fine to the profile screen.
Now in the profile screen when I hit my GUI button to load the first game scene(which works fine in the editor, but once again not in the Ouya), the screen goes black, and the game exits on the ouya back to the Ouya main menu.
I'll give you the entire code for the splash screen, and a code snippet for the load level portion of the profile screen to save bombarding code one ya.
Here's the code for the splash screen:
//Kurotatsu Studios Splashscreen script, modified from Unity wiki.
// SplashScreen Script
var guiDepth : int = 0;
var levelToLoad : String = "";
var splashLogo : Texture2D;
var fadeSpeed : float = 0.3;
var waitTime : float = 0.5;
var waitForInput : boolean = false;
var startAutomatically : boolean = true;
var timeFadingInFinished : float = 0.0;
var logoPositioning : LogoPositioning;
var splashType : SplashType;
enum SplashType {LoadNextLevelThenFadeOut, FadeOutThenLoadNextLevel}
enum LogoPositioning {Centered, Stretched}
private var alpha : float = 0.0;
private var status : FadeStatus = FadeStatus.FadeIn;
private var oldCam : Camera;
private var oldCamGO : GameObject;
private var splashLogoPos : Rect;
private var loadingNextLevel : boolean = false;
private enum FadeStatus {Paused, FadeIn, FadeWaiting, FadeOut}
function Start()
{
if (startAutomatically)
{
status = FadeStatus.FadeIn;
}
else
{
status = FadeStatus.Paused;
}
oldCam = Camera.main;
oldCamGO = Camera.main.gameObject;
if (logoPositioning == LogoPositioning.Centered)
{
splashLogoPos.x = (Screen.width * 0.5) - (splashLogo.width * 0.5);
splashLogoPos.y = (Screen.height * 0.5) - (splashLogo.height * 0.5);
splashLogoPos.width = splashLogo.width;
splashLogoPos.height = splashLogo.height;
}
else
{
splashLogoPos.x = 0;
splashLogoPos.y = 0;
splashLogoPos.width = Screen.width;
splashLogoPos.height = Screen.height;
}
if (splashType == SplashType.LoadNextLevelThenFadeOut)
{
DontDestroyOnLoad(this);
DontDestroyOnLoad(Camera.main);
}
if ((Application.levelCount <= 1) || (levelToLoad == ""))
{
Debug.LogWarning("Invalid levelToLoad value.");
}
}
function Update()
{
switch(status)
{
case FadeStatus.FadeIn:
alpha += fadeSpeed * Time.deltaTime;
break;
case FadeStatus.FadeWaiting:
if ((!waitForInput && Time.time >= timeFadingInFinished + waitTime) || (waitForInput && Input.anyKey))
{
status = FadeStatus.FadeOut;
}
break;
case FadeStatus.FadeOut:
alpha += -fadeSpeed * Time.deltaTime;
break;
}
}
function OnGUI()
{
GUI.depth = guiDepth;
if (splashLogo != null)
{
GUI.color = Color(GUI.color.r, GUI.color.g, GUI.color.b, Mathf.Clamp01(alpha));
GUI.DrawTexture(splashLogoPos, splashLogo);
if (alpha > 1.0)
{
status = FadeStatus.FadeWaiting;
timeFadingInFinished = Time.time;
alpha = 1.0;
if (splashType == SplashType.LoadNextLevelThenFadeOut)
{
oldCam.depth = -1000;
loadingNextLevel = true;
if ((Application.levelCount >= 1) && (levelToLoad != ""))
{
Application.LoadLevel(levelToLoad);
}
}
}
if (alpha < 0.0)
{
if (splashType == SplashType.FadeOutThenLoadNextLevel)
{
if ((Application.levelCount >= 1) && (levelToLoad != ""))
{
Application.LoadLevel(levelToLoad);
}
}
else
{
Destroy(oldCamGO);
}
}
}
}
function OnLevelWasLoaded(lvlIdx : int)
{
if (loadingNextLevel)
{
Destroy(oldCam);
}
}
function OnDrawGizmos()
{
Gizmos.color = Color(1, 0, 0, 0.5);
Gizmos.DrawCube(transform.position, Vector3(1, 1, 1));
}
function StartSplash()
{
status = FadeStatus.FadeIn;
}
and here's from the Profile screen:
if(GUI.Button(Rect(5,Screen.height -100,200,50), "Start Game.")){
if (profile == 1){
Profile1();
5.
}
if (profile == 2){
Profile2();
10. }
if (profile == 3){
Profile3();
}
}
function Profile1(){
PlayerPrefs.SetInt("profile", 1);
Application.LoadLevel(levelToLoad);
}
I don't see anything that could be causing it, which is why I'm asking.
Thanks for your time.
Kuro.
I think its a Unity 4.2 problem. Try playing with Depth buffers. But for what its worth, my problem like this went away after I SWITCHED PLATFOR$$anonymous$$ AND BAC$$anonymous$$ AGAIN Weird eh?
Wow, I'll try that. First the depth buffers idea(haveta do some googling.:D), then the switching platforms.
I'll post back if it works. Thanks meat5000.
Lots of people reporting the same problems. Some get fixed this way, some don't.
GOOD LUC$$anonymous$$ DUDE!!
No luck, same problem after I switched platforms.
If anyone is aware of other people having this problem and talking about it, please post a link here.
I'd sure hate to revert back to 3.5 unnecessarily.
Answer by BigToe · Aug 24, 2013 at 07:55 PM
I was having difficulty with 4.2 and what I believe is the same problem. I had a preloader scene with a splash graphic...It loaded my main menu screen which had a matching logo that would fade out...
With 4.2 there was a black flicker between the preloader screen and the main menu screen. If I reduced scripts it was a second, if I had all my init scripts in it took close to 3 or 4 seconds of black....Switching platforms didn't work.
My solution was to create a duplicate preloader scene to pass through before the main menu scene.
So I have preloader1 -> preloader2 -> main menu
Hope this might help you.
Your answer
Follow this Question
Related Questions
Game crashes or does not load levels when told to? 2 Answers
Level Not Loading After Screen Fade 1 Answer
Level Loading By 3D Text 1 Answer
Loading Screen? 6 Answers