Liviuss
New Member
Posts: 5
Posts: 5
|
Post by Liviuss on Oct 1, 2017 10:38:40 GMT
Hi,
I come into an issue with wrong assigned layers to spawned prefab.
Setup categories: [Units] -> Spawn on "Default" layer [UI] -> Spawn particles prefabs and static prefabs on UI (NGUI) layer [Fx] - > Spawn particles on a separate camera with separate layer.
For [UI] i spawn the prefabs with PoolBoss.SpawnOutsidePool method and i reparent the item with:
public GameObject HudParent; Transform CastleHUDt = PoolBoss.SpawnOutsidePool("CastleHUD",Vector3.zero,Quaternion.identity); CastleHUD = CastleHUDt.GetComponent<CastleHUD>();
CastleHUDt.parent = HudParent.transform; CastleHUDt.gameObject.layer = HudParent.layer; CastleHUDt.localPosition = Vector3.zero; CastleHUDt.localRotation = Quaternion.identity; CastleHUDt.localScale = Vector3.one; For the rest of items i use PoolBoss.SpawnInPool method. Every prefab in [Fx] category, has attached TimedDespawner script.
Problem: After 5-6 cycles on [Fx] category, prefabs start to get a layer from [UI] items (CastleHUDt.gameObject.layer = HudParent.layer)
The Workaround: At the moment i have to set the layer manually on spawn.
Thanks.
|
|
|
Post by DarkTonic Dev on Oct 1, 2017 18:43:32 GMT
Not very clear. If not for the layer problem, what does the code look like?
If it thinks that HudParent.layer is UI layer then it is at that moment, and I don't think this has anything to do with Pool Boss, but some Unity thing.
|
|
Liviuss
New Member
Posts: 5
Posts: 5
|
Post by Liviuss on Oct 1, 2017 18:58:33 GMT
Hi,
The problem is with prefab getting a wrong layer on spawning. And i can't reproduce this one, it's just come in sometime and only in editor. When deployed to device, i didn't noticed any issues. I should mention that i'm working with unity 2012.2.beta so maybe this behaviour it's not related to PoolBoss and it's something related to unity internals. You can close this thread as not possible to reproduce since i really don't understand what happens.
Thanks.
|
|
|
Post by DarkTonic Dev on Oct 1, 2017 19:19:39 GMT
If you think it's beta only, we can ignore it and try with the real version later. If you try on a released version of Unity let me know if you see a problem.
|
|
Liviuss
New Member
Posts: 5
Posts: 5
|
Post by Liviuss on Oct 6, 2017 10:49:30 GMT
Hi, So, i narrowed it down to the conclusion: PoolBoss is not ready to work with NGUI. 1. At first spawn cycle, when you spawn a prefab and parent to a NGUI panel, everything it's fine. 2. When you despawn the object, it will get parented back to PoolBoss GameObject but will keep layer and scale from NGUI parent. 3. At second cycle, when you spawn the same item, NGUI will parent the entire hierarchy(including PoolBoss GameObject) to the UI Root(seems that when you parent a widget, NGUI will start to track it) and you get screwed.
The solution is to have a "Don't Reparent" option. And as an improvement, to have a "Spawn on Layer" and "Spawn Scale".
Best
P.S. Another solution is to allow multiple instances of PoolBoss but it will need a redesign of entire component, moved back to PoolManager since it allow this kind of behaviour.
|
|
|
Post by DarkTonic Dev on Oct 6, 2017 15:50:09 GMT
Not going to allow multiple instances of PoolBoss. That's unneeded complexity and will make things that are currently smart and automatic not be that way anymore.
Why would step 3 do that? I don't understand why that happens. Let's get to the bottom of this and then figure out the list of things to investigate adding.
|
|
Liviuss
New Member
Posts: 5
Posts: 5
|
Post by Liviuss on Oct 6, 2017 23:55:25 GMT
|
|
|
Post by DarkTonic Dev on Oct 7, 2017 1:30:03 GMT
Ok thanks. Will add to roadmap.
|
|