Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: derkoi on September 15, 2012, 07:51:40 AM

Title: Level loading float variable?
Post by: derkoi 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.  :)
Title: Re: Level loading float variable?
Post by: jeanfabre 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/ (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
Title: Re: Level loading float variable?
Post by: derkoi on January 03, 2013, 03:42:29 PM
I eventually got it to work, with AsyncOperation.progress  ;D
Title: Re: Level loading float variable?
Post by: kiriri 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)
Title: Re: Level loading float variable?
Post by: derkoi 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.



Title: Re: Level loading float variable?
Post by: Red on January 03, 2013, 04:59:01 PM
hmm, will this work with the indie or is it a pro-only thing?
Title: Re: Level loading float variable?
Post by: KozTheBoss on January 03, 2013, 05:00:24 PM
oh my god this is just what I needed - Thanks for sharing this with us :)
Title: Re: Level loading float variable?
Post by: kiriri 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
Title: Re: Level loading float variable?
Post by: Red 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.)
Title: Re: Level loading float variable?
Post by: derkoi 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:

Title: Re: Level loading float variable?
Post by: Dev_Sebas on January 03, 2013, 05:19:49 PM
Nice feature.
Cheers
Title: Re: Level loading float variable?
Post by: TommyA 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
Title: Re: Level loading float variable?
Post by: jeanfabre on January 04, 2013, 02:44:19 AM
Hi,

hey!! that works!

 Is that a web player or a desktop publish?

bye,

 Jean
Title: Re: Level loading float variable?
Post by: derkoi 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
Title: Re: Level loading float variable?
Post by: TommyA 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?
Title: Re: Level loading float variable?[SOLVED]
Post by: derkoi on January 16, 2013, 06:51:04 AM
The only difference from my scene i can see is that I don't use a loaded event, maybe try yours without.

Also, because my scene loads faster on my PC the load bar only updates once, however on my iPhone & iPad it updates a couple of times, depending on the blocks loading i think.
Title: Re: Level loading float variable?
Post by: TommyA on January 16, 2013, 07:44:25 AM
Oh, It works!
When I import on my iPhone, it works.
It still looks dosen't works on Unity program but works on the iPhone.
Thank you in advance Derkoi. :)
Title: Re: Level loading float variable?
Post by: derkoi on January 16, 2013, 08:36:47 AM
Great stuff, I think it needs a build to work correctly.  :)
Title: Re: Level loading float variable?
Post by: aLDime on November 25, 2013, 07:05:17 AM
Hi all, how you got "Set Property / UISlider / etc"
Title: How you got "Set Property / ***UISlider ***/ ..."???
Post by: aLDime on November 25, 2013, 08:08:14 PM
That no one knows the answer to such easy question?
Title: Re: Level loading float variable?
Post by: jeanfabre on November 28, 2013, 02:59:12 AM
Hi,

 You simply drag the "UISlider" in the State stack and Playmaker will ask you if you want to "Set" or "Get" a property from UIslider.

Bye,

 Jean
Title: Re: Level loading float variable?
Post by: aLDime on November 30, 2013, 01:16:00 AM
Hi Jean,
I understand that should be simple, but I have no Object Type UIslider property ..
instead of this I have Unity Engine GO:
Title: Re: Level loading float variable?
Post by: jeanfabre on December 02, 2013, 01:52:09 AM
Hi,

 yes, because you are dragging the gameobject, you need to drag the component itself,  then you will have access to that component class public variables.

bye,

 Jean
Title: Re: Level loading float variable?
Post by: aLDime on December 02, 2013, 02:35:06 AM
Thanks a lot, Jean, everything works fine, the only thing you have not explained that FSM must be on the my "Progress Bar Loading" (on Slider), otherwise access to the component is not possible, but this is what I guessed myself;)
Just a big thank derkoi for a very valuable custom action!
Title: Re: Level loading float variable?
Post by: jeanfabre on December 02, 2013, 02:36:32 AM
Hi,

 nop, the fsm can be anywhere, you don't need to be on the same gameobject of the component you want to access.

 what you may struggle with is the technic to actually have two unity inspector or simply lock the fsm so that you can select another gameobject and then drag one of its component.

bye,

 Jean
Title: Re: Level loading float variable?
Post by: aLDime on December 02, 2013, 03:18:56 AM
Yes, exactly, thanks again!
Third way, just copy (Copy States) where it is necessary and remove the excess (such as Slider) ;)
Title: Re: Level loading float variable?
Post by: derkoi on January 03, 2014, 09:20:21 AM
Just a big thank derkoi for a very valuable custom action!

No problem, glad you're finding it useful.