- Home /
GUI depth change!!
hi i have a script for scene loading in background while show a full screen image with a waiting video. but the problem is if the image is stretched it covers the loading video too, i want to show the loading video on the above of the image. can anyone help me out!! here is my code (c#), i just put a part of the code where the movie texture and 2d texture function with fade. if you need full code please leave a comment.
void OnGUI()
{
PlayVid.loop = true;
PlayVid.Play();
GUI.DrawTexture(new Rect (Screen.width - 260,Screen.height - 110,260,110), PlayVid);
GUI.depth = guiDepth;
if (splashLogo != null)
{
GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, Mathf.Clamp01(alpha));
GUI.DrawTexture(splashLogoPos, splashLogo);
if (alpha > 1.0f)
{
status = FadeStatus.FadeWaiting;
timeFadingInFinished = Time.time;
alpha = 1.0f;
if (splashType == SplashType.LoadNextLevelThenFadeOut)
{
oldCam.depth = -1000;
loadingNextLevel = true;
if ((Application.levelCount >= 1) && (levelToLoad != ""))
{
Application.LoadLevel(levelToLoad);
}
}
}
if (alpha < 0.0f)
{
if (splashType == SplashType.FadeOutThenLoadNextLevel)
{
if ((Application.levelCount >= 1) && (levelToLoad != ""))
{
Application.LoadLevel(levelToLoad);
}
}
else
{
Destroy(oldCamGO); // somehow this doesn't work
Destroy(this);
}
}
}
}
Answer by Quillicit · Jul 05, 2013 at 03:40 AM
Couple of things. First, GUI.depth can only be changed from another script, unless you're using an instance in this script, so I believe your GUI.depth is doing nothing. Second, the first thing to be rendered in your OnGUI will be at the greatest depth (farthest from the camera). The next thing rendered will go on top of the first. Try moving PlayVid.Play() to the end of your OnGUI and see if that works.
Your answer
Follow this Question
Related Questions
JS changing gui box color 1 Answer
Load level that was previously loaded! 1 Answer
change detail in game an the sound? 3 Answers
Changing a GUI texture while hovering over an object? 2 Answers
Changing a material with a mouse click 2 Answers