Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started 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. :)
-
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
-
I eventually got it to work, with AsyncOperation.progress ;D
-
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)
-
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.
-
hmm, will this work with the indie or is it a pro-only thing?
-
oh my god this is just what I needed - Thanks for sharing this with us :)
-
hmm, will this work with the indie or is it a pro-only thing?
the entire Async is pro only
-
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.)
-
oh my god this is just what I needed - Thanks for sharing this with us :)
No problem. ;D
This is the finished result:
-
Nice feature.
Cheers
-
That's exactly what I wanted!
Awesome!
I will try this right now.
Thank you again :D
-
Hi,
hey!! that works!
Is that a web player or a desktop publish?
bye,
Jean
-
Is that a web player or a desktop publish?
It's a mobile publish actually, iOS to be exact. ;D
-
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?
-
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.
-
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. :)
-
Great stuff, I think it needs a build to work correctly. :)
-
Hi all, how you got "Set Property / UISlider / etc"
-
That no one knows the answer to such easy question?
-
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
-
Hi Jean,
I understand that should be simple, but I have no Object Type UIslider property ..
instead of this I have Unity Engine GO:
-
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
-
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!
-
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
-
Yes, exactly, thanks again!
Third way, just copy (Copy States) where it is necessary and remove the excess (such as Slider) ;)
-
Just a big thank derkoi for a very valuable custom action!
No problem, glad you're finding it useful.