Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
6
Question by Colin Allen · Jan 11, 2011 at 08:29 PM · scenescene-loadingloadinglevel

Loading Screen?

Hi,

I have a qeustion,

I want to make a loading screen, somthing that says "Loading". but i dont want to have to make a new scene per level. basicly, if a level is loading, can i make it spawn a GUI everytime its loading somthing.

i know this is very hard to explain but i need a little help.

Comment
Add comment · Show 6
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image makram · May 24, 2011 at 09:01 AM 0
Share

this script not work

avatar image pitso 7 · May 01, 2012 at 04:09 AM 0
Share

hello so i am new to unity and i do not understand where to put the loading scene script can anybody help me i know I'm asking this and its a stupid question but nobody really explained where to put it

avatar image Bunny83 · May 01, 2012 at 04:11 AM 0
Share

@pitso: This is not an answer to the question! Use comments is you have a short question about a specific post. If you have a real question, post a question-

avatar image Bonkurazu · May 06, 2014 at 07:27 PM 0
Share

O$$anonymous$$, might I suggest a basic idea (maybe someone who gets what I'm saying put it in code form, because at this moment I don't have time to do that :P): basically, you use a CUSTO$$anonymous$$ function named "CustLoadLevel" in a level loader script, with one string argument "levelToLoadCust". Then have all objects that could possibly need to send a message to load the level to have a reference to an object with CustLoadLevel so they can use ".Send$$anonymous$$essage". Then, have the level loader script read in the level and before loading the level, overlay a GUI item with the loading texture, so while the next level is loading the screen is displaying the loading screen while remaining in the same level. I dont know I'll refine this later, I guess.

avatar image Student465789 · May 15, 2015 at 05:39 AM 0
Share

this is Brilliant... I was going to use a scene for my loading but this is easier and all I really want is a meteor spinning so this should work for that?

void Update() { if(!Application.isLoadingLevel) hide(); }

public static void loadLevel(string sceneName) { LoadingScreen.show(); Application.LoadLevel(sceneName); }

Show more comments

6 Replies

· Add your reply
  • Sort: 
avatar image
9
Best Answer

Answer by Statement · Jan 11, 2011 at 10:10 PM

Sure, here is a script I created.

It acts like a singleton, and you can easily set it up in your first scene. Just give it a texture and you are all set. You can use it like LoadingScreen.Load(levelIndex); and it will show the texture on screen.

using UnityEngine;

public class LoadingScreen : MonoBehaviour { public Texture2D texture; static LoadingScreen instance;

 void Awake()
 {
     if (instance)
     {
         Destroy(gameObject);
         return;
     }
     instance = this;    
     gameObject.AddComponent<GUITexture>().enabled = false;
     guiTexture.texture = texture;
     transform.position = new Vector3(0.5f, 0.5f, 0.0f);
     DontDestroyOnLoad(this); 
 }

 public static void Load(int index)
 {
     if (NoInstance()) return;
     instance.guiTexture.enabled = true;
     Application.LoadLevel(index);
     instance.guiTexture.enabled = false;
 }

 public static void Load(string name)
 {
     if (NoInstance()) return;
     instance.guiTexture.enabled = true;
     Application.LoadLevel(name);
     instance.guiTexture.enabled = false;
 }

 static bool NoInstance()
 {
     if (!instance)
         Debug.LogError("Loading Screen is not existing in scene.");
     return instance;
 }

}

Comment
Add comment · Show 8 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Colin Allen · Jan 12, 2011 at 04:27 PM 0
Share

i dont think it worked. mabey its because i dont have much to load. idk. thanks anyways :D

avatar image Statement · Jan 12, 2011 at 04:39 PM 0
Share

Does it give an error message? Did you set a texture to use?

avatar image Matt Carver · Mar 03, 2011 at 03:51 PM 0
Share

I'm looking for something similar and I came across this script and I've been trying to get it to work.

I could be wrong about this, but shouldn't the NoInstance() function be called as:

if(!NoInstance()) return;

Otherwise when the instance does exist, NoInstance() will true and the Load function will exit without actually loading the scene.

avatar image MachCUBED · Dec 07, 2012 at 03:00 AM 0
Share

I tried it, and while it's loading my stuff just fine with no error messages, it's stil not showing the image that I set as my loading image. The script is attached to a GameObject with the same transform as the camera in my initial scene, and the transform of the GameObject has no effect on what shows up. FTR, I'm using this in conjunction with NGUI.

avatar image Marek_Bakalarczuk · Jan 23, 2013 at 10:00 AM 0
Share

Statement, how to use your script? It doesn't show an image when loading

Show more comments
avatar image
7

Answer by Dreamer · Jun 11, 2011 at 06:02 PM

I found out to do loading screen is so easy after I implemented myself. Here is to share with everyone:

 static var loading_on : boolean;
 var Loading_Screen:Texture2D;
 
 function OnGUI () {
     if(loading_on){
         GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3(1.0*Screen.width/GameData.X, 1.0*Screen.height/GameData.Y, 1.0));
         GUI.depth =-10;
         GUI.Box(new Rect(0,0,1024,768),Loading_Screen);
     }
     if(!Application.isLoadingLevel)
         loading_on=false;
 }
Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image TheFrankman123 · Apr 16, 2012 at 06:21 PM 0
Share

Would you attach this to the main camera?

avatar image TheFrankman123 · Apr 16, 2012 at 06:31 PM 0
Share

also i'm getting unknown identifier GameData

avatar image landon912 · Aug 18, 2012 at 06:13 PM 0
Share

How would this work you never set loading_on to true. Wouldn't you need
If(Application.isLoadingLevel){ loading_on = true; }

avatar image st362 · Dec 19, 2012 at 04:31 PM 0
Share

You may attach this to any camera, I have $$anonymous$$e attached to an object. When someone clicks on the object, I turn loading_on=true; Then my loading screen is activated. The GameData is just a placeholder, you must adjust the GUI.matrix to whatever size you want. GUI.matrix translates, scales, and rotates your loading screen. This loading screen is working really good if you want something simple, thanks for sharing!

avatar image Shadowys · May 19, 2014 at 01:00 PM 0
Share

The loading_on variable is redundant, just the Application.isLoadingLevel is enough, though. :P

 def OnGUI ():
     if Application.isLoadingLevel:
         GUI.Box(Rect(0,0,Screen.width,Screen.height),Loading_Screen)
         GUI.Label(Rect(Screen.width/2-10 , Screen.height*3/4, 200, 100),loading.ToString()+" %")
         loading+=Random.Range(10,30)
avatar image
5

Answer by lliviu · Sep 07, 2013 at 06:29 PM

Statement's code didn't work for me. Here is the modified version:

 using UnityEngine;
 using System.Collections;
 
 public class LoadingScreen : MonoBehaviour
 {
     public Texture2D texture;
     static LoadingScreen instance;
  
     void Awake()
     {
         if (instance)
         {
             Destroy(gameObject);
             hide();
             return;
         }
         instance = this;    
         gameObject.AddComponent<GUITexture>().enabled = false;
         guiTexture.texture = texture;
         transform.position = new Vector3(0.5f, 0.5f, 1f);
         DontDestroyOnLoad(this); 
     }
     
     public static void show()
     {
         if (!InstanceExists()) 
         {
             return;
         }
         instance.guiTexture.enabled = true;
     }
         
     public static void hide()
     {
         if (!InstanceExists()) 
         {
             return;
         }
         instance.guiTexture.enabled = false;
     }
     
     static bool InstanceExists()
     {
         if (!instance)
         {
             return false;
         }
         return true;
         
     }
  
 }


I call i from my GameController class like this:

     public static void loadLevel(string sceneName)
     {
         LoadingScreen.show();
         Application.LoadLevel(sceneName);
     }

Don't forget to put it on an empty object and set the texture.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image arjunu · Apr 19, 2014 at 04:49 PM 0
Share

Tried this but LoadingScreen still exists after new scene loads!

avatar image MachCUBED · Apr 20, 2014 at 12:40 AM 0
Share

Does that mean that the LoadingScreen object exists even though a new scene loads?

avatar image arjunu · May 07, 2014 at 12:03 PM 0
Share

@$$anonymous$$achCUBEd yes

avatar image mmangual_83 · May 15, 2014 at 07:53 PM 0
Share

I found a solution, take his exact code but add this to the LoadingScreen class:

 void Update()
 {
    if(!Application.isLoadingLevel)
       hide();
 }



What its doing is that it checks if the application is loading a level. If not, then hide the splash screen.

avatar image
3

Answer by Fervent · Feb 06, 2012 at 07:49 PM

I just put a post up about this at Fervent Interactive Blog

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1
Wiki

Answer by Bonkurazu · May 15, 2015 at 08:27 AM

How about something like this

 //meant to be placed on a GameObject other ones can have a reference to so activation with .SendMessage is possible
 //UNTESTED
 
 using UnityEngine;
 using System.Collections;

 public class CustomAsyncLoader : MonoBehaviour 
 {
 //objects / stuff to show
 
   void Start(){} //forgot if this is required for a MonoBehaviour
 
   void Update(){} //ditto
 
   void customLoadLevelAsync(String level) //call to load level
   {
     //show graphics somehow, possibly via rendering with a camera with a higher depth than all other ones
     AsyncOperation asyncOp = Application.loadLevelAsync(level);
     yield return asyncOp;
     Debug.log("Load to " + level + " success.");
   }
 }

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image AnnoyingRain5 · Mar 18, 2016 at 05:01 AM 0
Share

void start and void update isn't required for a $$anonymous$$onoBehaviour

  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

LoadSceneMode.Single seems to be not working. 0 Answers

How to have the scene load after a few seconds 1 Answer

RPG - Battle loading, Scene Management. 1 Answer

Possible to load scenes from directory? 3 Answers

Classic Resident Evil-style room loading/level streaming? 4 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges