I suppose complicated is relative, but it's mixed objects in here. I'm creating a UI prefab and having trouble getting it to render when I instante it via NGUITools.AddChild.
My test scene consists of MainCamera, GUICamera, and a SceneHUD gameobject which contains the UIRoot component.
I'm instantiating the prefab like this:
var go = NGUITools.AddChild(sceneHUD, (GameObject)Resources.Load("RacingHUD"));
foreach (var anchor in go.GetComponentsInChildren<UIAnchor>()) {
anchor.uiCamera = uiCamera; // this is a ref to GUICamera set in the inspector
}
The prefab spawns, and the transforms of each element looks as though it should, but nothing is rendering.
If I include the toplevel SceneHUD (with UIRoot) in the prefab and instantiate that whole thing, everything works fine.
Is there something about including anchors or non UI-gameobjects in the prefab that I'm not picking up on?
The prefab's hierarchy:
SceneHUD (part of Scene, not in the prefab, the first argument to NGUITools.AddChild)
---RacingHUD (empty G.O.)
------CenteredAnchor
---------Panel
------------CountdownLabel (UILabel)
------TopLeftAnchor
---------Pane
------------FirepowerLabel (UILabel)
------------PrimaryPowerups (empty G.O.)
---------------Bomb (non-UI object with MeshRenderer)
------------SecondaryPowerups (empty G.O.)
---------------Boost (non-UI object with MeshRenderer)
------------powerupBOx (SlicedSprite)
------------powerupBOxActivated (SlicedSprite, with the sprite component disabled with the intentioning of enabling/disabling in code)
---------PowerupSelector (G.O. with display logic script attached)