Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: vallcrist on December 17, 2013, 10:26:07 PM
-
Hello again.
So, I found a weird bug (?) in 3.0.7.
See, our game has a "InGame UI" prefab, in which we setup the GUI for all our playable levels, it's a prefab so we can only change in one place, apply and all levels get updated.
Before, with 3.0.6- anchor system, all worked well, however, with 3.0.7 when we have a widget anchored to a panel, say, to the bottom left, ( like this http://ctrlv.in/271863 ) and we save the prefab, be it creating a new one or applying the current one, something weird tends to happen, like this http://ctrlv.in/271864.
It is as if it was anchored to the bottom left, at (0,0,0). Sometimes we get weirder results, like the widget shrinking to 2x2 dimension or going to ( 190000000, 12312344, 0 ).
Any ideas?
-
Prefabs can't reference targets outside the prefab. I'm guessing you have your prefab anchored to an object that's not a part of your prefab?
-
I encountered this same thing with similar setup (ingame UI prefab) when upgrading from 3.0.7 f2 to f3 and the prefab is not anchored to outside objects. Things behave correctly on runtime but for some reason in editor it gets messed up when pressing Apply, etc (afterwards it still works in runtime if I remember correctly). If I enable 'Offset anchors by position' in panel the glitch does not appear.
-
Yup, nothing is being referenced from outside the prefab.
Looks like ticking the "Offset anchors by position" box kinda solves it for me as well, but i have no idea why.. any thoughts on this, Aren?
-
Might be related to another issue. I'll have a look.
-
I have been encountering this issue as well, specifically widgets in my prefabs shrinking to 2x2. I am certain my prefabs are not anchored to any GameObject external to it (other than using UIStretch with no container defined to stretch a UIPanel across the entire viewport--is this relevant?) Thanks to this thread, I have been enabling "offset anchors by position" as a temporary workaround.
-
I seem to be encountering a similar issue. Though it could be simply because the new Anchor system doesn't work in the same way as the previous UIAnchor/UIStretch system.
Previously, I could attach a UIAnchor to a GameObject, with the target being the UICamera. I could save this as a Prefab - Obviously the UICamera wasn't a part of this prefab, but when instantiated, the Anchor and Stretch realised that they required one, and would find the UICamera in the scene, and apply it as the target for the Anchor.
The new Anchor system doesn't seem to do this anymore? Is this correct? If so - is there another way to create a prefab that when instantiated will be position and scaled relative to the current UICamera ?
To break it down :
Old Anchor/Stretch :
UIWidget "obj"
- UIAnchor component: using UI Camera as the target.
I save "obj" as a prefab. When I instantiate "obj", the UIAnchor component gets populated with the current UICamera in the scene.
New system :
UIWidget "obj2"
- UIWidget Anchor, Unified with Target = UICamera
Saved as Prefab.
When "obj2" is instantiated, the entire Anchor section is gone, and the anchor is not applied.
-
There is currently a known issue related to instantiating anchored prefabs. It should be already addressed in 3.0.8. If not, I will revisit it after I'm done with the current set of changes for 3.0.8 b2.
-
Just updated to 3.0.8 f2 and the issue still exists.
-
What issue is that? You can't reference objects and scripts inside a prefab that are not a part of the prefab. It's how Unity works. You mention referencing a UICamera... unless you explicitly set this anchor after instantiating your prefab, the reference will not be kept. Think about it... how can a prefab reference something that's not a part of it?
-
Thing is, as I tried to say previously, in my case (and some others as well I guess) the prefab does not reference anything outside it nor I'm attempting to anchor it - it's self contained with root object having UIRoot, UIPanel. Then UICamera as children, widgets as camera's children and so on. Now if I disable 'Offset anchors' from panel, all widgets just disappear somewhere when pressing Apply. This was fine in 3.0.7 f2 and broke in 3.0.7 f3 (where I found that the offset option makes it work again) and is still broken in 3.0.8 f2.
-
Can you give me a set of steps to follow so I can reproduce it on my end using the stock atlases that come with NGUI?
-
Okay here goes. Tested on a clean project with only NGUI being imported. Unity 4.3.1f1 on OS X 10.8.5, NGUI 3.0.8 f2.
1. Open scene 'Example 1 - Anchors'.
2. Make prefab of 'UI Root' by dragging it to project window.
3. You should now see that all the corner anchored stuff are gathered around center instead. Toggling 'Offset anchors' on panel makes the issue appear/disappear. In playmode things work correctly even if the positions appear wrong in editor.
-
Thanks, I will investigate.
-
I've found the issue and fixed it in the Pro repository. You will see the fix live in 3.0.8 f3.