playMaker

Author Topic: Don´t Load All Prefaps at Level Load [SOLVED]  (Read 2902 times)

Xenocalypse

  • Playmaker Newbie
  • *
  • Posts: 13
Don´t Load All Prefaps at Level Load [SOLVED]
« on: November 20, 2016, 09:57:22 AM »
Hello Masters of Playmaker, i got stuck again.

I made a game with hundreds of Levels. I grouped them in to a pack of 10 Levels Each Prefab. (The Levels Using a hell Lot of Global Variables ) the game is using about 15000. No matter it runs smooth. I Load and Unload after every 10 Levels, and i Destroy the old 10 Levels and get the next 10 by creating new game object.
So far this is working without any Problem.

But as everything is in one Level...or better in One Scene. If i Load the scene, i got heavy Load times cause it seems to load all the Prefabs, "Levels " befor you can play.

That was not my intention on creating prefabs for all 10 Levels. Because i want to keep Loading time Down.

I´m really a noob. Is there anyway to create this Levels, Without them loaded on Sceneload? 

I heard Something bout resource load, but how do you break the reference then, i´ts still a prefab, right ? or is the reference the action that create that Prefab in the Level.

Anyway, i want the Prefab to be loaded, if needed not on Scene load.

Thx for any Help, very very much. And if anyone can help, (Yes shame on me)
pls be detailed. i just beginn to learn. and its quite cool till now^^

Thx Thx Thx.

edit: After a bit of reading, don´t know if the Problem is the Prefab, or the 15000 Globals i Use ?...

Are all Global Load at Scene Load, even if the Prefab wich use them is not in the Scene on Start?

Getting confused now
« Last Edit: November 21, 2016, 06:52:37 AM by Xenocalypse »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Don´t Load All Prefaps at Level Load
« Reply #1 on: November 21, 2016, 03:20:43 AM »
Hi,

 yes, you would put your prefabs in a Resources folder and use ResourcesLoad custom action from the Ecosystem to load them and instantiate them using CreateObject action.

with Resources, the reference is the path to your source, that's all ( without the extension).

https://docs.unity3d.com/ScriptReference/Resources.html

that way you'll prevent start up loading, and can differ the loading for when you show first a "Loading" page or warning to let the user know there will be a wait time.

try first with a simple prefab, and once you figured it out, work with a more complex prefab. you can also use subfolders inside your resources, but be careful, ALL resources folder are root, so if you have several Resources folder with duplicated prefab names, it will pick up the first one it finds under that relative path,



 Bye,

 Jean


Xenocalypse

  • Playmaker Newbie
  • *
  • Posts: 13
Re: Don´t Load All Prefaps at Level Load
« Reply #2 on: November 21, 2016, 05:11:53 AM »
Hey Jean,

so if i understand you, i Create a Resources Folder, put my Level Prefabs in there,
and call them with the resource Load Action if needed, this way they Don´t load on start and don´t load all the Globals in it ? Sounds very good and easy, will try it.

Thx in advanced

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Don´t Load All Prefaps at Level Load
« Reply #3 on: November 21, 2016, 05:16:38 AM »
Hi,

 globals are going to be loaded, they are defined at a project level, so you won't cut down on global loading, only on fsms structures, which is already a big deal anyway so it's definitly something to consider.

 indeed, if you have 15000 global variables, you went wrong big time... sorry :)

 you need to think more with object oriented deisng in mind, with local variables. I can't imagine that you have lots of interdependancies iwth these globals, I would say 99.9% of them do not need to global, and could be local variables just fine. Other fsm needing to set or get a value would simply use "GetFsmXXX" or "SetFsmXXX" actions and done.

but, yeah, if you have 15000 globals, refactoring is likely out of questions...


 Bye,

 Jean

Xenocalypse

  • Playmaker Newbie
  • *
  • Posts: 13
Re: Don´t Load All Prefaps at Level Load
« Reply #4 on: November 21, 2016, 05:29:01 AM »
You don´t have to be sry^^ I´m a noob.

I didn´t found a workaround not to use Globals.

I have a Spawner Object, which Spawns a GameObject wich was bevor randomly choosen and stored in a Gameobject Global.

1. So i use select random game Object and store it.
2. I need this Spawned Object to be a Child of my Spawner Object...so if i use set parent i need to use The Global Again.
There Are 35 Spawners Each choose From 12 objects, 110 Levels. And some Other Obejcts that spawn things asswell....and all need to be childs of the spawner....

anyway i try your resource Load thing first ^^

thx

Xenocalypse

  • Playmaker Newbie
  • *
  • Posts: 13
Re: Don´t Load All Prefaps at Level Load
« Reply #5 on: November 21, 2016, 06:28:29 AM »
You are my Hero, this works like a charm! Resource load cuts down Loading time to nearly zero even on old android devices.

thank you so much ! And tuff now you know Playmaker can Handle 15000 Globals without a problem. Just you need to close the Globals Window from Playmaker while Editing, otherwise the Editor gets really slow.

And a Triple thx again!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Don´t Load All Prefaps at Level Load [SOLVED]
« Reply #6 on: November 22, 2016, 01:59:46 AM »
Hi,

 cool.

 and I just released a new custom action on the Ecosystem which asynchronously load resources which could also help you along the way if your resources are very big,

https://twitter.com/JeanAtPlayMaker/status/800954886963666944

Bye,

 Jean