playMaker

Author Topic: Nested Prefabs  (Read 8657 times)

FractalCore

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 100
Nested Prefabs
« on: November 18, 2012, 11:22:03 PM »
Has anyone tried one of the two Nested Prefab plugins on the Asset store (or know of any others). They're both a bit pricey but I'm definitely buying one. I really need nested prefab functionailty. If there was only one it would be an easy choice.


Nested Prefab $35

http://u3d.as/content/bento-studio/nested-prefab/2Jz

The cheaper one. But also more complex. You save the prefabs as some other kind of prefab file. No reviews, and couldn't find a forum post about it. But it seems to be VERY well documented.


Prefabs in Prefabs $45

http://u3d.as/content/databox-games/prefabs-in-prefabs-plugin/2Px

http://forum.unity3d.com/threads/131685-Prefabs-in-Prefabs-plugin-available-now-at-the-Asset-Store

More expensive, but easier. It simply lets you drop prefabs inside prefabs and just works... However, in the Unity forum the last several posts are about it running slow or throwing up errors, and the author hasn't replied.


Has anyone here had a go and could recommend one.

My use would be to really thrash it. I need it to perform as well as the regular prefabs do already. And, obviously it should play well with Playmaker.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Nested Prefabs
« Reply #1 on: November 19, 2012, 12:29:10 AM »
Hi,

 Is Unity 4 not coming up with nested prefabs? According to Aren Mook it has:
http://www.tasharen.com/forum/index.php?topic=2014.0

but I haven't really found any documentation on that..

bye,

 Jean

FractalCore

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 100
Re: Nested Prefabs
« Reply #2 on: November 19, 2012, 12:55:50 AM »
Yeah I found the part of the big presentation video where the guy on stage mentioned it (right before the big Unity GUI demonstration). What Unity 4 does with prefabs looks pretty good. But I also heard it doesn't have nesting until a later 4.x update. Either way I'm not interested in Unity 4 until it gets some more useful features. I don't mind splashing out on a solution now. Maybe I should flip a coin.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Nested Prefabs
« Reply #3 on: November 19, 2012, 01:07:34 AM »
Hi,

 yeah... difficult choice...

What's your exact need for nested prefab?

bye,

 Jean

FractalCore

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 100
Re: Nested Prefabs
« Reply #4 on: November 19, 2012, 01:30:03 AM »
At the moment I'm experimenting with environments.

In a perfect world I'd have a prefab of a chunk of land. Inside that is a whole lot of tree and grass prefabs with their own LOD settings. Being prefabs I could change anything about them at any time.

Currently in Unity, I can either have all the prefabs as children under the chunk of land that's NOT a prefab. This means I can't instantiate it using Playmaker at run time. OR I can have my instantiatable land but all the trees and grass are locked in and can't be changed accept one at a time.

All my experiments keep leading back to "if only I could have prefabs inside prefabs".

Right now I have a square km of land. 25 200x200m separate landscape objects exported out of max. I used Max's tools to spread around over 3000 tree and grass objects for each landscape. Got them into Unity and used an editor script I found to replace all of those with their prefab version (very cool). But now they have to have that connection broken, which is sad. I use Playmaker to create a get distance to player system that either creates or destroys the thousands of foliage objects based on distance. That plus turning on the static batching seems to work perfectly, so I can create my own terrain system.

And this is why, if I try one of these plugins out, it has to be fast.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Nested Prefabs
« Reply #5 on: November 19, 2012, 01:36:38 AM »
Hi,

 And why not creating levels? and load them on demand? each portion would be a level and you load it asynchronously when required.

bye,

 Jean

FractalCore

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 100
Re: Nested Prefabs
« Reply #6 on: November 19, 2012, 01:39:55 AM »
I'm not sure what's possible with that, I haven't tried it. Do you mean you can load a section or environment as a level in the distance while you're still on the current level. Treating squares of land as levels that are already in the right place and fit around each other, is that possible?

FractalCore

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 100
Re: Nested Prefabs
« Reply #7 on: November 19, 2012, 01:47:34 AM »
Holy crap. I just tried that out. It works. This will require more investigation.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Nested Prefabs
« Reply #8 on: November 19, 2012, 04:53:44 AM »
Hi,

 yep, that's how they do on big games, they load asynchronously on demand. But also don't forget that you will need some kind of system to also destroy areas you don't see or as far from the use, else you will have memory problems. It depends if you reuse prefafs between these portions or not tho.

bye,

 Jean

FractalCore

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 100
Re: Nested Prefabs
« Reply #9 on: November 19, 2012, 02:16:03 PM »
It worked at first, then I remembered the landscape (level) I was loading had no foliage objects. It was just the landscape and my Playmaker system which was still instantiating the non prefabbed foliage. And of course the purpose of this is to be able to have thousands of prefabs sitting in the level ready to be loaded in the distance.

So I brought them all in, individual LOD's all set up so they won't even display when they appear (out of range). And there's a big pause while it loads. I didn't have the Async option ticked. So I tried it but nothing changed, instead it gave this message in the console;

LoadLevelAdditiveAsyc: _Scene-02
UnityEngine.Debug:Log(Object)
HutongGames.PlayMaker.Actions.LoadLevel:OnEnter() (at Assets/PlayMaker/Actions/LoadLevel.cs:54)
HutongGames.PlayMaker.FsmState:OnEnter()
HutongGames.PlayMaker.Fsm:EnterState(FsmState)
HutongGames.PlayMaker.Fsm:SwitchState(FsmState)
HutongGames.PlayMaker.Fsm:DoTransition(FsmTransition, Boolean)
HutongGames.PlayMaker.Fsm:ChangeState(FsmEvent)

_Scene-02 is the level being brought in, in the distance. The Asynchronous loading is supposed to load the level in the background so it can appear instantly, right? So this might be a bug, or is that not what the Async option is for?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Nested Prefabs
« Reply #10 on: November 20, 2012, 02:35:48 AM »
Hi,

 Don't worry about the logs, they are actually from the LoadLevel action. You could simply comment them out on the action script, but I would not recommand it as this gives you a good indication of what is going on in the background.

Asnyhronous world management is a beast. So yes, be prepared... I would recommand getting as much documentation and read forum threads on google and UDN to get a good idea of where to go and what are the pitfalls and other areas to watch out for.

bye,

 Jean

FractalCore

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 100
Re: Nested Prefabs
« Reply #11 on: November 20, 2012, 04:19:39 AM »
But in using asynchronous level loading, is it supposed to freeze the game while it loads. Or is the action not working.

The information I found suggested asynchronous loading is for use on a static loading screen. So you wouldn't notice a pause and then it continues once the level has loaded. Is this suitable for what I'm attempting with a continuous landscape.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Nested Prefabs
« Reply #12 on: November 20, 2012, 07:54:03 AM »
Hi,

 In my experience, you will get some freeze time, I never was able to load smoothly any big assets... maybe I am just missing the obvious tho.

  It's not related to PlayMaker usage, so if you do experience gamePlay freeze, I suggest you get in touch with Unity forums and Unity answers to get a feel of what is the expected behavior. Thos Maybe someone from this forum will have a better experience on this topic.

bye,

 Jean