Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: Bradamante3D on September 04, 2014, 04:52:13 PM
-
Hi,
my hierarchy is built like this:
"Panel" (UIPanel with clipping + UIScrollView)
+ "Sprite" (UIDragScollView + Box Collider + UIWidget)
++ "Stuff 1"
++ "Stuff 2"
++ ...
Thing is, NGUI complains with:
Widgets and panels should not be on the same object! Widget must be a child of the panel.
UnityEngine.Debug:LogError(Object, Object)
UIWidget:OnStart() (at Assets/NGUI/Scripts/Internal/UIWidget.cs:1042)
UIRect:Start() (at Assets/NGUI/Scripts/Internal/UIRect.cs:430)
But isn't it? Or does UIDragScrollView count as a Panel?!
EDIT:
Got it. I have it that when I click the "Stuff" buttons, I use a manual call to SpringPanel.Begin() to position the "Sprite". In that moment, a UIPanel gets added and NGUI complains.
When I use a manual transform.position = newPos, there's no problem.
NGUI misbehavior or should I set my stuff up differently?
-
It sounds correct. This only happens if a widget (label or sprite) is on the same object as a UIPanel. You can look through all your Panels by searching for t:UIPanel and see if any of them has a widget on it as well.
-
Well, it has, no secret, see the Hierarchy in my first post.
I am using the UIWidget to give the scrolled content, which the elements are parented to, a certain size (1920x1440 in this case). Is there a different way to achieve this?
-
The hierarchy you wrote says nothing about widgets and panels being on the same gameobject. UIDragScrollView does not count as a panel.
The intermediate "Sprite" is fine, it looks to be correct.
Which object does the LogError point to when you click it in the console?
-
I understand I should have been more clearer.
As described in my edit, SpringPanel.Begin() adds a UIPanel to the "Sprite" GameObject. At that moment, NGUI complains, since now a UIPanel and a UIWidget are on the same GO.
Should I introduce another layer of hierarchy? Am I totally off?
The hierarchy you wrote says nothing about widgets and panels being on the same gameobject.
-
You should not be using SpringPanel.Begin on a game object. It should only be used on scroll views. I don't know why you are trying to use it on a non-panel...
-
Alright, got it. Basically I used SpringPanel.Begin to achieve a behavior that actually UICenterOnChild is for. It works now.
SpringPanel.Begin however did have the same effect, only that Unity throws an error. I used it like: SpringPanel.Begin ( "Sprite" ) - see the first post. "Sprite" is the holder GameObject of the content objects, with the UIDragScrollView on it.