Hey-yo, forum.
I'm using NGUI 3.6.1, and have stumbled upon a little problem.
Most of my GUI is constructed on-the-fly, using premade prefabs and dynamic instantiation (using AddComponent).
Yet, UIDraggableCamera effectively forbids such behaviour, by making a check for rootForBounds inside Awake:
void Awake ()
{
mCam = camera;
mTrans = transform;
if (rootForBounds == null)
{
Debug.LogError(NGUITools.GetHierarchy(gameObject) + " needs the 'Root For Bounds' parameter to be set", this);
enabled = false;
}
}
making dynamic instantiation such as the one below throw an error:
UIDraggableCamera draggableCamera = DraggableCamera.AddComponent<UIDraggableCamera>();
draggableCamera.rootForBounds = SomeOtherGOInstance.transform;
draggableCamera.dragEffect = UIDragObject.DragEffect.None;
so, i need an explicit .enable call to make things right (it won't remove the LogError, ofc).
draggableCamera.enabled = true;
The question is: why would UIDraggableCamera need such a check inside Awake?
Judging by the implementation, the only unchecked call to rootForBounds is inside Update.
... So moving the check to Start would fix things? P.S. I've checked the forum for similar threads, and found and old one,
http://www.tasharen.com/forum/index.php?topic=1144.msg5896 , that doesn't have any point.