Search Unity

Scene Pre-Loader

Discussion in 'Assets and Asset Store' started by merlin981, Sep 9, 2013.

  1. merlin981

    merlin981

    Joined:
    Apr 16, 2012
    Posts:
    305
    Scene Pre-Loader for Unity allows you to send all your GameObjects to the GPU when the scene starts, forcing the GOs to be loaded and cached in the GPU. The Scene Pre-Loader includes a progressbar with optional game hints, which show the progress as the items are cached.

    Pre-Loading your GameObjects can also speed up your level as the player progresses, as it reduces lag/slowdowns when new GameObjects are instantiated into the scene.

    Documentation

    Demo

    Scene Pre-Loader in Asset Store
     
  2. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Does this work with unity free or just pro?
     
  3. merlin981

    merlin981

    Joined:
    Apr 16, 2012
    Posts:
    305
    It works for both Free and Pro, but it does require NGUI. I included the free version of NGUI with the package
     
  4. Snaxz

    Snaxz

    Joined:
    May 13, 2013
    Posts:
    15
    How does it do with iOS and Android builds?
     
  5. merlin981

    merlin981

    Joined:
    Apr 16, 2012
    Posts:
    305
    I haven't tried on iOS, but it worked fine when I tested on my Android phone. There isn't anything in this package which is platform dependent, so it should work on any platform Unity supports.
     
  6. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,609
    Is NGUI really needed? Is it ingame? I'd buy it if it didn't need NGUI.
     
  7. merlin981

    merlin981

    Joined:
    Apr 16, 2012
    Posts:
    305
    This package makes heavy use of NGUI. I believe (but have not confirmed) that the free version of NGUI will work for this package.
     
  8. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,609
    Any ways to make it work without it? I'd rather not use the free version as there are watermarks.
     
  9. merlin981

    merlin981

    Joined:
    Apr 16, 2012
    Posts:
    305
    It would require a complete re-write in order to work without NGUI. However, all the source code is included with the package, so you (or someone else) could see how I've done the pre-loader and then write a custom implementation without using NGUI.

    NGUI is used for several aspects of this package:
    * Hiding the scene while everything loads in the background
    * Displaying the progress bar as items are pre-loaded
    * Displaying the background image and instruction labels
     
  10. Zeblote

    Zeblote

    Joined:
    Feb 8, 2013
    Posts:
    1,102
    The point of this has nothing to do with NGUI so why would it require NGUI?
     
  11. n8

    n8

    Joined:
    Mar 4, 2010
    Posts:
    147
    So I have a question about this package. I am using the free version of Unity and so I am completely unable to use the "loadlevelasync" functions. My main scene is quite large and on ios devices (specifically iPad2) loading that scene takes a very long time to load. at the moment I throw up a "loading" message, but the time is so long that most testers think the app has frozen. Given this information, would this package actually help me? How would this package get around the inability to call "loadlevelasync"? Do you load an intermediate scene that handles the loading in some other way?

    Thanks in advance
     
  12. merlin981

    merlin981

    Joined:
    Apr 16, 2012
    Posts:
    305

    Hi n8,

    Scene Pre-Loader does not use loadlevelasync, and does not load a second level.

    From the documentation:

    The first thing displayed is the NGUI window, which hides everything in your scene, then the code iterates through all the objects you specify and sends them to the GPU to pre-loaded. Each object represents a tick on the progressbar, so users actually see the progress of items being pre-loaded. Once all items are pre-loaded, then NGUI window deactivates and your scene can start.
     
  13. n8

    n8

    Joined:
    Mar 4, 2010
    Posts:
    147
    ok so all of this happens after a scene has been loaded? Basically what I am trying to figure out is how the main scene is loaded. If I have an intro scene that has a series of buttons that once clicked will load the corresponding level. Currently I load the level with Application.LoadLevel("level_whatever") and then wait while Unity basically freezes all update cycles until the next scene is ready to go. What I am confused with is when does your package spring into action? after I load my scene and it is active but not yet initialized? Or do I make a call to your package that handles all of the loading of the next scene for me giving me the nice animated loading bar and pre-cached GOs?

    Thanks in advance for your response. I want to make sure that this package is solving my problem before I purchase.
     
  14. merlin981

    merlin981

    Joined:
    Apr 16, 2012
    Posts:
    305
    Sure...

    You would use the pre-loader on the scene that takes a long time to load....

    So, show your first screen with the buttons. When a button is clicked, the new (long loading) scene is loaded as you normally load it.

    However, when you set up the scene, you just add the pre-loaded prefab and populate its component properties. It does the rest for you.

    What takes a long time to load in your scene is all the objects that are in view of the camera, these must all be cached by the GPU. The pre-loader stops them from being drawn on screen, so the pre-loader will appear first. Then, the pre-loader loops over all the objects you specify and caches them with the GPU.

    As mentioned earlier, you will need NGUI for this to display properly. The free version of NGUI will work just fine.
     
  15. n8

    n8

    Joined:
    Mar 4, 2010
    Posts:
    147
    Ok great! that sounds like it does a great job of getting around the inability to use the async loading of scenes on the free version. If I were you, I would probably make that a little more clear on your description in the asset store. I am sure that I would have bought this right away if that had been more clear. Just a little advice to possibly boost sales for you ;) On my way to purchase now!
     
  16. n8

    n8

    Joined:
    Mar 4, 2010
    Posts:
    147
    Ok purchased, and everything seems to be working great. I made one small change to your script however. At the end of the process of loading the gameobjects you are disabling the root NGUI object which is a UIRoot class. I modified your script to just use a standard GO instead of an NGUI UIRoot. I couldn't find any reason why you were using UIRoot over Gameobject. I already use NGUI and have a UI built, so I just added a panel for the loading window. The original setup was completely disabling my UI rendering my scene unplayable. Switching from UIRoot to GO seems to solve the issue without causing any other bugs.


    On a second note, do you have any recommendations for speeding up the load time from the point I hit the button to load new scene to the point where your loader shows on screen? At the moment there is still considerable amount of time between hitting "Load scene" button and the time that the progress bar shows up.

    Thanks! the asset is working great so far otherwise!
     
  17. merlin981

    merlin981

    Joined:
    Apr 16, 2012
    Posts:
    305
    Thanks for the suggestion about the UIRoot / GameObject. I'll put that on my list to update the package.

    One thing you might try is deactivating everything in your scene when you build the scene. The pre-loader will actually activate it, cache it, then deactivate it. Then, when pre-loading is finished, you can have a script that activates each object you need on scene start.

    (Hmmm, I'm actually going to add this to my list, too :D but don't expect an update until later this month).
     
  18. merlin981

    merlin981

    Joined:
    Apr 16, 2012
    Posts:
    305
    I've submitted a new version to Unity, which should be available in the next few days, with the following changes:

    * NguiLoaderWindow is now a GameObject (instead of a UIRoot)

    * Added a new property to the SceneObjects array – “Set Active When Finished Loading”. When this is set to true (default), the object will be set Active after it has been pre-loaded. This is useful if you have all your objects deactivated on start so the pre-loader can load them first.

    * Added a SendMessage event - ScenePreLoaderCompleted() – which is called when the pre-loader has completed loading all scene objects. Register by calling ScenePreLoader.RegisterListener(gameObject).
     
  19. merlin981

    merlin981

    Joined:
    Apr 16, 2012
    Posts:
    305
    New version has been approved by Unity and is now available on the store.
     
  20. gshape

    gshape

    Joined:
    Aug 8, 2012
    Posts:
    104
    Hi! I used this asset in my iOs game and it works great so far... apart from the progress bar never goes to 100%. (in my case, it always ends at 5~6%).
    Therefore, I looked into the script and found that this line might be wrong.
    ProgressStepValue = (float)NumObjectsToParse / 10000;

    I changed it to this and it seems working fine now.
    ProgressStepValue = (float)1/NumObjectsToParse;

    Also, the new function "Set Active When Finished Loading" doesn't work in my case. Game objects doesn't set to active after loading.

    Thanks.
     
    Last edited: Mar 17, 2014
  21. merlin981

    merlin981

    Joined:
    Apr 16, 2012
    Posts:
    305

    Thanks, I will take a look at both.

    I suspect the progressbar value is due to a change in NGUI v3, as I originally wrote this for NGUI 2.7.

    I will have an update published to Unity later this week.
     
  22. merlin981

    merlin981

    Joined:
    Apr 16, 2012
    Posts:
    305
    Ok, new version pushed to Unity, should be available in a few days
     
  23. merlin981

    merlin981

    Joined:
    Apr 16, 2012
    Posts:
    305
    New version is approved and is now available for update via the Asset Store. :D
     
  24. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,160
    No offense, but in my opinion, making an asset (not GUI related) that require NGUI is absurd. Not so many people are using NGUI, (or yes?).
    I think the new GUI system (Unity 4.6) probably will change this.
     
    Last edited: Mar 27, 2014
  25. merlin981

    merlin981

    Joined:
    Apr 16, 2012
    Posts:
    305
    I'm sure it will. Until then, we are left NGUI, Daikon Forge, or using the built-in GUI system. Personally, I prefer NGUI and Daikon Forge (until Unity 4.6ish).

    I think you'd be surprised how many people use NGUI
     
  26. Asza

    Asza

    Joined:
    Jun 24, 2014
    Posts:
    1
    Hi thanks for this asset i have some questions:

    1. Is there a video tutorial on how to use this package? I think the documentation is kinda vague. If not I have a few questions:

    2.If i have a spawner that initiates prefabs are those prefabs preloaded as well? If not i guess i have to put the prefabs in the list so they are preloaded?

    3. In the documentation on step "f" it says: Ngui Loader Window - The NGUI Root window for the Pre-Loader' i guess you mean the UI ROOT?

    4. I want to use the loadingscreen on a level that starts right away. How do i "freeze" the game until it is done loading?

    5. I got the loading bar to work but the GUI wont dissaper once it is done loading. Again a video tutorial would be really helpful :)

    Thanks!
     
    Last edited: Jul 2, 2014
  27. merlin981

    merlin981

    Joined:
    Apr 16, 2012
    Posts:
    305
    Hi Asza,

    Thanks for using Scene Pre-Loader.

    1) I don't have a video, yet. I do have it on my to do list, but probably won't have one ready until the end of the month.

    2) You have to put the prefabs into the preloader list if you want it preloaded. You can just put one instance of each base prefab in the preloader list.

    3) Yes, the UIRoot

    4) The preloader has the option to SendMessage to any scripts that register, when it finishes loading. My general process is to have a the preloader do a SendMessage to a script I call "StartManager". The StartManager would be responsible for "starting" the scene. Also, you do have the option for the preloader to Activate a list (or sub-list) of objects After if finishes preloading the scene.

    5) Can you PM me a screenshot of your Console after the scene finishes loading?
     
  28. inianbharathi

    inianbharathi

    Joined:
    Sep 26, 2013
    Posts:
    6
    Hi merlin,
    sorry for asking same question ,but u mentioned in asset store that Scene preloader package is bundled with free version of unity .So will it have water mark, when i use this in our game or should i buy NGUI pro.Thanks in advance.
     
  29. merlin981

    merlin981

    Joined:
    Apr 16, 2012
    Posts:
    305
    I don't think the free version of NGUI has a watermark (but I could be mistaken). I believe the free version of NGUI simply has some limitations of which widgets you can use
     
  30. Prasanna

    Prasanna

    Joined:
    Feb 4, 2014
    Posts:
    2
    Hi merlin,
    i have purchaced your scene preloader asset .When i load my prefabs in your script i get following error
    1.)null reference exception
    or
    2.)Prefab game object cannot be made active

    It will be greatly appreciated if you could provide us with a tutorial video for this asset .Thanks in advance.
     
  31. merlin981

    merlin981

    Joined:
    Apr 16, 2012
    Posts:
    305
    Hi Prasanna,

    I'd be happy to review your scene if you want to share it with me in PM.

    Thanks,
    Philip
     
  32. Prasanna

    Prasanna

    Joined:
    Feb 4, 2014
    Posts:
    2
    Hi Philip,
    Thanks for your response i solved those issues .I Build my game as web player build ,Everything works fine but when i load the game in slow internet connection.My next scene does not get loaded and it stays in same screen when i click play button, before its cached.I purchased Preloader hoping that this could be solved .Can u guide me what could be done .Is there any other solution so that game runs a loading screen until all objects are cached to run the game seamlessly.
     
  33. merlin981

    merlin981

    Joined:
    Apr 16, 2012
    Posts:
    305
    Hi Prasanna,

    I'm glad you were able to solve your issue.

    The preloader needs to be in the same scene that is being preloaded. It doesn't load up a new scene, it preloads the current scene.
     
  34. nution

    nution

    Joined:
    Nov 7, 2012
    Posts:
    10
    Whats the advantage of loading things into the GPU? I'm a bit confused on this. Specifically for mobile and large scenes.
    Should we put everything in the scene to be preloaded into the GPU? Or just some things with meshes?

    Also, when we transition from say the Main menu scene to Scene1 (lvl1) it takes about 5 seconds, normally. With this it still does have that "pause" inbetween scenes, then this preloader gui shows, takes about 3-5 seconds and the level starts. Would I assume right that this package doesnt help that transition? And we need to have essentially two different loading views? One for the normal "pause" loading a scene and one for this preloader?
     
  35. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,357
    I am a bit confused, if the scene is already started then how does it pre-load it ? It just loads it.

    So i guess this will work with the normal LoadLevel in Unity free too ? Very interesting indeed

    What is the loading speed increase comparing to the normal loading ?

    Also how does it work ? It loads the gameobjects in the scene and resources folder from the HDD and have them ready to be used when needed ? I guess this is what you mean when saying "reduces lag/slowdowns when new GameObjects are instantiated into the scene" in the asset desciption ?

    Or you mean object instantiated from scene objects only ?

    Also if Unity does load things gradually and does not pre load them, wouldnt they have a reasoning behind it ? I mean could this method create problems for the performance, if everything is in the GPU at all times in say a very big/complex scene ?

    Thanks
     
    Last edited: Sep 3, 2014
  36. merlin981

    merlin981

    Joined:
    Apr 16, 2012
    Posts:
    305
    When a scene normally loads in Unity, all objects in view of the camera and active are sent to the GPU for caching. Most scenes have a lot of objects (terrain, trees, GOs, etc) which need to be cached on the GPU at scene start.

    The other performance issue in a scene is the objects which have not been cached but become active later in the scene. These must first be cached in the GPU before they can be rendered in the scene.

    Scene Pre-Loader (SPL) handles this for you. You first set all your scene objects inactive, then provide the list of objects to SPL. SPL uses a special pre-loading camera to force each object into the GPU (one time, during scene load), so everything is cached and there are no performance hits when you later activate an object.

    Plus, SPL provides a progressbar to show the loading progress, so your users know the scene is loading.
     
  37. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,357
    I see, so the main thing it does is pre-load everything in the scene, even the inactive and out of camera items, for smooth loading when they do become active

    It will come in handy for sure, thanks for clarifying
     
  38. merlin981

    merlin981

    Joined:
    Apr 16, 2012
    Posts:
    305
    Yes, correct
     
  39. inianbharathi

    inianbharathi

    Joined:
    Sep 26, 2013
    Posts:
    6
    Hi Merlin,
    Our game works fine on offline.But when we stream the game from web.When clicked play,The second scene buffers slowly and scene remain in current main menu .Our game size is 6.5 mb .We understand that we need a preloader or atleast some load progress bar indicating the stream is in progress.We used load level async and we even purchaced scene preloader from asset store .But the package just works in current scene .It doesnt preload the entire game.Your asset greatly increased our games individual scene speed ,but doesnt solve the issue.We will be very thankful to you if u could help us from this situation.I have attached link to the game
    http://griffininfosystems.com/games/TEST_LOAD/
     
  40. merlin981

    merlin981

    Joined:
    Apr 16, 2012
    Posts:
    305
    Thank you for the kind words.

    If you're streaming the download, you'll need a different progress bar for showing the download of the scene. You'll still need scene pre-loader within the downloaded scene.

    If you use the WWW class from Unity, it includes a progress property that will give you the real time progress of the download (0-1). You can use this to update your progress bar as the scene is downloading.

    Hope this helps
     
  41. merlin981

    merlin981

    Joined:
    Apr 16, 2012
    Posts:
    305
    I've published a new update which which should be available later this week on the Asset Store. The update is redesigned using the latest version of NGUI and Unity. The demo scene and script have been updated, as well.

    This should be available as an update for you by the end of the week.

    Thanks,
    Philip
     
  42. shanky_91

    shanky_91

    Joined:
    Dec 1, 2012
    Posts:
    2
    Incrementally load your scenes in Unity (including free version) while displaying a loading screen and bar!
    SceneLoader

    Can be combined with Scene pre-loader to allow you to display a loading bar while loading and "pre-loading" the level
     
  43. UltraTM

    UltraTM

    Joined:
    Dec 8, 2013
    Posts:
    221
    Hi,

    got a problem.

    My Scene loads from 0,00 to 12,8 % then bam loading screen is gone.
    When i add more i get it on 100. When i add then again more cause im building more in the Scene its 100% and still loading a long time.

    Also the Progressbar is not nice.
    Took an background and and foreground image. But he handles it like a progress bar slider and stretches my foreground image until it fits. That looks ugly :(

    what do i make wrong?
     
    Last edited: Jan 20, 2015
  44. merlin981

    merlin981

    Joined:
    Apr 16, 2012
    Posts:
    305
    Hi UltraTM,

    Do you have any exceptions posted in the log?

    My first guess is that the object being parsed at 12.8% threw an exception.

    Thanks,
    Philip
     
  45. patchworkx

    patchworkx

    Joined:
    Nov 8, 2014
    Posts:
    20
    don`t get it.. i just have to direct debug the code in unity 5.... but i`m also not to much into it ..--- can u might fix that issiue from box.._
    next i will -would like to combine your scene preloder with thegraph maker (https://www.assetstore.unity3d.com/en/#!/content/11782)... might u can explane how to transfair the valius..????