playMaker

Author Topic: Level loading float variable?  (Read 12454 times)

derkoi

  • Full Member
  • ***
  • Posts: 187
Level loading float variable?
« on: September 15, 2012, 07:51:40 AM »
I'd like to using an NGUI progress bar to show the progress of the loading level in my game.

The NGUI bar takes a float value from 0-1, is there anything in Playmaker that can read the loading state and give a float value out?

Thanks.  :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Level loading float variable?
« Reply #1 on: September 16, 2012, 07:53:27 AM »
Hi,

 I think this is not possible, I could be wrong, but every attempt I did failed, I think they are not supporting this even tho the api is there.

 what I can do tho is to check on level loading streaming when the application starts, NOT when you actually need it. Do you get the difference?

 that is when the unity application starts, it will stream levels, you can get the progress of that, check my excavator demo, it does it at the beginning.
http://www.fabrejean.net/projects/excavator/

 Maybe someone can step in and have some code that works for when you actually want to load a level during the game.

bye,

 Jean

derkoi

  • Full Member
  • ***
  • Posts: 187
Re: Level loading float variable?
« Reply #2 on: January 03, 2013, 03:42:29 PM »
I eventually got it to work, with AsyncOperation.progress  ;D

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: Level loading float variable?
« Reply #3 on: January 03, 2013, 04:09:29 PM »
I eventually got it to work, with AsyncOperation.progress  ;D

woah, how does that work? I too have failed so many times and you just tell us that there's a premade function? :D

But seriously, how does it work? I had a long discussion about this topic once and I thought an excact loading progress is either too expensive, as it would have to actually guess how long each byte takes to load, or inaccurate, if it just takes the loaded bytes vs the still left bytes ratio (which I tried and which doesn't work at all, at least it did not in Unreal)
Best,
Sven

derkoi

  • Full Member
  • ***
  • Posts: 187
Re: Level loading float variable?
« Reply #4 on: January 03, 2013, 04:29:56 PM »
I modified the load level action slightly.  ;D

All you need to do is create a new scene with the loading progress bar and whatever you want i have "loading..", you go to this loading scene when you want to load a level, this then immediately loads the real level.

I use NGUI so you might have to figure out how to use whatever it is you use but I've added the action and a screen shot that shows how I set it up.

Load Progress is a float value & in the script it's multiplied by 100, this is because AsyncOperation.progress gives you between 0 and 1 but rounds the value off for some reason, so it doesn't work. By multiplying by 100 it works. For my NGUI slider value it needs between 0 and 1, so i divided by 100.

Let me know if you need more of an explanation.



« Last Edit: January 03, 2013, 05:26:17 PM by derkoi »

Red

  • Hero Member
  • *****
  • Posts: 563
Re: Level loading float variable?
« Reply #5 on: January 03, 2013, 04:59:01 PM »
hmm, will this work with the indie or is it a pro-only thing?

KozTheBoss

  • Full Member
  • ***
  • Posts: 150
  • You dont fail unless you give up trying to succeed
    • Pixel Life - portfolio
Re: Level loading float variable?
« Reply #6 on: January 03, 2013, 05:00:24 PM »
oh my god this is just what I needed - Thanks for sharing this with us :)
Remember, you don't fail unless you give up trying to succeed!

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: Level loading float variable?
« Reply #7 on: January 03, 2013, 05:02:56 PM »
hmm, will this work with the indie or is it a pro-only thing?
the entire Async is pro only
Best,
Sven

Red

  • Hero Member
  • *****
  • Posts: 563
Re: Level loading float variable?
« Reply #8 on: January 03, 2013, 05:08:10 PM »
hmm, will this work with the indie or is it a pro-only thing?
the entire Async is pro only

bummer... because i'm cheap (well, it's because i don't have the $$ to drop on the pro version... yet... yet.)

derkoi

  • Full Member
  • ***
  • Posts: 187
Re: Level loading float variable?
« Reply #9 on: January 03, 2013, 05:10:59 PM »
oh my god this is just what I needed - Thanks for sharing this with us :)

No problem.  ;D

This is the finished result:


Dev_Sebas

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 398
    • Blog
Re: Level loading float variable?
« Reply #10 on: January 03, 2013, 05:19:49 PM »
Nice feature.
Cheers

TommyA

  • Playmaker Newbie
  • *
  • Posts: 26
Re: Level loading float variable?
« Reply #11 on: January 04, 2013, 01:42:56 AM »
That's exactly what I wanted!
Awesome!
I will try this right now.
Thank you again  :D

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Level loading float variable?
« Reply #12 on: January 04, 2013, 02:44:19 AM »
Hi,

hey!! that works!

 Is that a web player or a desktop publish?

bye,

 Jean

derkoi

  • Full Member
  • ***
  • Posts: 187
Re: Level loading float variable?
« Reply #13 on: January 04, 2013, 03:20:07 AM »
Is that a web player or a desktop publish?

It's a mobile publish actually, iOS to be exact.  ;D

TommyA

  • Playmaker Newbie
  • *
  • Posts: 26
Re: Level loading float variable?
« Reply #14 on: January 16, 2013, 06:42:36 AM »
I tried to test this action but couldn't get a proper result.
Maybe something wrong with my settings..
I made button (load scene button) and progress bar(loading progress bar) with NGUI.
When click button, it transit to state which contains "load level with progress", "float divide", "set property" as you posted.
The scene is loaded but the "loading" float value doesn't change so there's no update to sliderValue of progress bar.
Any idea of what did I wrong?