x


Load level

How do I go about making a screen with a loading bar? I am using substancs all over the place and I would like it to be able to go from my main menu to a loading screen where it would load all the assets then take into game play?

more ▼

asked May 02 '12 at 03:15 PM

Davidflynn gravatar image

Davidflynn
61 22 49 55

Don't know who disliked this, but I liked it again...

May 02 '12 at 06:18 PM Hybris

Thanks not sure what would be wrong with the question.

May 02 '12 at 06:21 PM Davidflynn

me neither, well I posted an answer go check it out!

May 02 '12 at 06:23 PM Hybris
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

Hello,

I made this little script that should do the trick, first you have to create a new scene(HAS TO BE VERY SMALL), with GUI or whatever(I used GUI) and apply this script to the GUI:

Trying to paste full code again :

 #pragma strict
 var level : String;
 var loadingbar : GUITexture;
 var MaxloadingWidth : float;

 function Update() 
 {
     if (Application.GetStreamProgressForLevel(level) == 1)
     {
         loadingbar.pixelInset.width = MaxloadingWidth;
         Invoke("Loadinglevel", .5);
     }

     if (Application.GetStreamProgressForLevel(level) <= 1)
     {
         loadingbar.pixelInset.width ++;
     }
 }

 function Loadinglevel()
 {
     Application.LoadLevel(level);
 }

Srry, can't guarantee this to work, I got a very small scene to load so it loads immediatly. But I think this will work

Good luck,

Hybris

more ▼

answered May 02 '12 at 06:23 PM

Hybris gravatar image

Hybris
415 5 8 10

Worked great thanks so much!!

May 02 '12 at 06:26 PM Davidflynn

Why am I getting "Trying to Invoke method: LoadingScreen.Loadinglevel couldn't be called." :S

Jan 28 at 01:57 PM robounited

As @Davidflynn never actually accepted this answer, I'm upvoting this answer ( also to reflect the kindness shown by Hybris in removing the negative vote from the question ).

@robounited it looks like some of the code is missing (possibly due to UnityAnswers updates). If you read up on Invoke, you will see that Invoke("Loadinglevel", .5); is looking to call a function Loadinglevel, which would then I assume initializes the next scene. I have never done this so cannot help, but maybe David or Hybris can re-submit the code.

Jan 28 at 03:53 PM alucardj

I'll see what I can do. Right now, I can't do anything. Indeed some of the code is missing and i'll update it as soon as possible.

Feb 01 at 06:16 AM Hybris

It seems that I can't get it to work properly, the code doesnt want to show up, that's why the code will be right here:

#pragma strict
var level : String;
var loadingbar : GUITexture;
var MaxloadingWidth : float;

function Update () {

if(Application.GetStreamProgressForLevel(level) == 1){
    loadingbar.pixelInset.width = MaxloadingWidth;
    Invoke("Loadinglevel", .5);

}

if(Application.GetStreamProgressForLevel(level) <= 1){
    loadingbar.pixelInset.width ++;

}

}

function Loadinglevel (){

Application.LoadLevel(level);

}

There it is.

PS: I'm not sure if I should make this an answer or keep it a comment.

For some reason it just won't work..

Feb 01 at 06:28 AM Hybris
(comments are locked)
10|3000 characters needed characters left

I don't what plugins you have access to, if any, but one very easy way to do this is to use the UIBtnLoadScene in the EZ GUI library. All you need to do is add this control to the game object that will trigger the new scene to load, and specify what panel to show while the new scene loads (game objects are initialized).

I know this is a specialized solution since it uses the EZ GUI plugin, but I thought it was at least worth posting in case you currently use or are considering using EZ GUI.

more ▼

answered May 02 '12 at 04:17 PM

casperas14 gravatar image

casperas14
31 1 1 1

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x298
x256

asked: May 02 '12 at 03:15 PM

Seen: 911 times

Last Updated: Feb 02 at 11:37 AM