Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Prodigga

Pages: [1] 2
1
NGUI 3 Support / Re: Updating anchors on Late Update instead
« on: February 05, 2015, 07:49:40 PM »

2
NGUI 3 Support / Re: [3.5.6] Culling issue? Elements are hidden
« on: February 05, 2015, 07:00:28 PM »
Didn't work for me. Whatever NGUI seems to be doing 'under the hood' that is causing my elements to be culled (and never reactivated) seems to just happen again when I run the function.

It's like NGUI doesn't expect my elements to come back on screen again - NGUI doesnt 'realize' the elements are moving. My Tweener tweens the position of the parent element and moves it from being completely off-screen to completely on-screen. It is initially spawned off-screen, so NGUI does whatever culling it does to get rid of those elements (as they are off screen) but it doesn't think to re-run that culling process when the elements are tweened back on to screen. Everything remains invisible.

When the tween is complete and the elements are completely on-screen, I can call "ImmediatelyCreateDrawCalls" as you've suggested and everything becomes visible again! But this doesn't help me because I need to see the elements tween on screen haha.

3
NGUI 3 Support / Re: Updating anchors on Late Update instead
« on: February 05, 2015, 06:36:29 PM »
Basically I have a scroll view full of widgets w/ transparent backgrounds. Then, outside of the scroll view, I have a UIWidget that has its top anchor anchored to the top of the scroll view and bottom anchor anchored to the bottom of the last element in the scroll view. This makes it stretch from the top of the list to the bottom element of that list, and it updates correctly when the user drags the scroll view up and down. It is easier to just show you:


Anyway, it all works fine, except for the update issue I mentioned above. After testing, the strange culling issues I mentioned before seem to be unrelated (I reverted my LateUpdate modification and still had issues with a vanilla UIRect class, so I've posted here.

I've modified UIRect and given it a LateUpdate as well as an Update function. I've added a public bool to UIRect (UseLateUpdate) and if it is checked, the UIRect will run on late update (otherwise the LateUpdate just returns immediately. This way, I don't modify the way NGUI works too drastically - only some of my anchors are updating on LateUpdate and those anchors generally belong to widgets that sit at the bottom of the hierarchy tree and don't have any other objects anchored to them. Havn't had any issues with it so far, its working well!

4
NGUI 3 Support / Re: [3.5.6] Culling issue? Elements are hidden
« on: February 04, 2015, 01:26:49 AM »
I have this issue aswell. All my elements are uniformly scaled and I am using NGUITools.MarkParentAsChanged, but some of my elements are still getting culled. It happens to me when I use a Tweener to tween the position of a panel from somewhere offscreen to onscreen.

What I do is I tween the panel off screen, delete its contents, populate it with new content (using NGUITools.AddChild), and finally tween the panel back on screen. I keep having UIWidget that get culled - invisible in the scene view/game view, generate no mesh that I can see in the wire-frame view, completely culled. If I disable that UIWidget in the inspector and reenable it, it renders correctly.

5
NGUI 3 Support / Updating anchors on Late Update instead
« on: February 03, 2015, 10:33:05 PM »
Hey guys

Sometimes, some of my widgets' anchors seem to late begin a single frame. This happens a lot when I have widgets/panels anchored to a widget/panel inside of a scroll view that is moving. When the user drags the scroll view, the objects in the scroll view update and move correctly, but anything outside of the scroll view anchored to those objects lag behind.

I was able to fix this issue by editing UIRect and UIWidget and replacing all the Update calls with LateUpdate. Everything was anchored correctly after that. However, it seems to have brought rise to some culling issues. Sometimes, newly instantiated objects inside of scrolls views won't render correctly (invisible) until I move the scroll view a little.

I don't know what other implications my change would have, so thats why I thought I'd come here first and ask about it. What would I potentially be breaking with this change?

6
NGUI 3 Support / TouchScreenKeyboard.area always returns (0,0,0,0)
« on: October 09, 2014, 02:08:48 AM »
Hey guys

I am just trying to move my UI above the on screen keyboard, but the function that returns the onscreen keyboard size is always returning 0. TouchScreenKeyboard.visible returns the correct values, but not TouchScreenKeyboard.area. I was wondering if this was a problem with NGUI's UIInput's conflicting with something? What is the standard way to get the keyboard size?

Also, slightly offtopic, is there a way to hide the white input box with the "ok" button next to it when I summon the on screen keyboard? I am typing directly into my input field so there is no need to see the input twice.

7
Thanks, thats just what I thought.

Ok just one more question. I am assuming you use vertex colors to tint the widgets different colors. Does this mean that in the following example:

-UIPanel (+Scroll view)
--UIWidget
---*Labels, etc*
--UIWidget
---*Labels, etc*
--UIWidget
---*Labels, etc*

If I was the change the "color" of one of the widgets, the entire UIPanel will rebuild?

8
Ok good to know! What if instead the UIWidgets were all rotating? Then it would be better to make them panels right? What about scaling? Or using the UITween position instead of scrolling them? Do all those cause the parent panel to rebuild the meshes?

9
NGUI 3 Support / When should I start putting Widgets in their own UIPanels?
« on: September 24, 2014, 03:08:53 AM »
Hey guys,

So I have a much better understanding of how NGUI does batching and how panels work. From what I've read, resizing/moving panels is cheaper than widgets, because the widgets will rebuild the mesh if you move/rotate/scale them.

I've got a panel with a scroll view. Underneath it is 3 UIWidgets which are 3 pages of data (They contain some labels, etc). You navigate these pages by swiping side to side.

All of this is 1 draw call because I only use a single UIPanel. But would it be better to break up each page into its own sub-panel? The scroll view is scrolling those 3 UIWidgets - from what I understand, this means that the panel must regenerate the mesh of all its children because those widgets are now moving? Is this correct? If the contents of those 3 widgets was static, and I made them UIPanels instead, then NGUI won't have to regenerate the meshes?

-UIPanel (+Scroll view)
--UIWidget
---*Labels, etc*
--UIWidget
---*Labels, etc*
--UIWidget
---*Labels, etc*

vs

-UIPanel (+Scroll view)
--UIPanel
---*Labels, etc*
--UIPanel
---*Labels, etc*
--UIPanel
---*Labels, etc*


Edit:

Or would this make a difference?

-UIPanel (+Scroll view)
--UIPanel
---UIWidget
----*Labels, etc*
--UIPanel
---UIWidget
----*Labels, etc*
--UIPanel
---UIWidget
----*Labels, etc*

10
Hey there. I need to create what is essentially a thread of comments (like this forum), where each post has a variable height (determined by the label inside, which is set to 'adjust height' depending on its contents). I also need a sliced sprite for this label as the background, and this sliced sprite needs to match the size of the label + some padding.

Lastly, I need to be able to add these comments as children of a table so that I can reposition the table and order the comments vertically.

I can't seem to get this to work, regardless of how I set my anchors  I always have these problems where the anchors wont 'settle' and theyll slowly crawl off screen.

11
Awesome stuff, thanks. The AddChild + ResetAnchors + UpdateAnchors functions solved a lot of issues for me. Cheers!

12
Ok well.. UIStretch was a bad example. But the problem is very real. Adding things to existing widgets programatically is a massive pain. Most things just don't work. I think I am not doing something correctly. Everything always works so perfectly in the editor but when i replicate those steps at run time through code, i get funny results.

I've attached a repo project to this post. Import the latest NGUI (3.6.6 as of writing this) to your project and import my package. Check out the 2 scenes. In one of them, I've precreated a scrollable list of items that stretch to fit the scroll view (resize the viewport and you'll see this in action). In the second scene I am doing it through code and it just doesn't work even though the outcome appears to be the exact same in the inspector.

What am I doing wrong, or what else should I be doing?

13
I am having a lot of issues with objects not updating correctly when I add things programmatically (UIStretch doesn't stretch to fill contents, etc (many more cases similar to this)). Is there some 'proper' way to add ui elements to the scene programmatically that forces all the relevant objects to refresh correctly? I keep having size and position errors in my elements. The only way I can avoid this issue if the wait atleast one frame and then call reset position (or something similar, ie reposition on UIGrid). This only works after I wait a frame. So my code is quickly becoming very messy especially when I need to refresh an element inside an element - I need to wait a frame, refresh the parent, wait a frame and refresh the child.

Is there some NGUI function that will ensure things are correctly updated?

14
I got it working. For anyone with the same problem, here is what I did:

In UIPanel, replace CalculateConstrainOffset with

  1. public virtual Vector3 CalculateConstrainOffset (Vector2 min, Vector2 max, bool SnapToTopOfGrid = false)
  2.         {
  3.                 Vector4 cr = finalClipRegion;
  4.  
  5.                 float offsetX = cr.z * 0.5f;
  6.                 float offsetY = cr.w * 0.5f;
  7.  
  8.                 Vector2 minRect = new Vector2(min.x, min.y);
  9.                 Vector2 maxRect = new Vector2(max.x, max.y);
  10.  
  11.                 Vector2 minArea = new Vector2(cr.x - offsetX, cr.y - offsetY);
  12.                 Vector2 maxArea = new Vector2(cr.x + offsetX, cr.y + offsetY);
  13.                
  14.  
  15.                 if(SnapToTopOfGrid)
  16.                 {
  17.                         UIGrid ChildGrid = GetComponentInChildren<UIGrid>();
  18.                         if(ChildGrid != null)
  19.                         {
  20.                                 BetterList<Transform> childs = ChildGrid.GetChildList();
  21.                                 UIWidget lastChildWidget = childs[childs.size-1].GetComponent<UIWidget>();
  22.                                 float childHeight = lastChildWidget.CalculateBounds().extents.y;
  23.                                 float newExtentY = -cr.w;
  24.                                 newExtentY+=childHeight;
  25.                                 if(newExtentY < minRect.y)
  26.                                 {
  27.                                         minRect.y = newExtentY;
  28.                                 }
  29.                                
  30.                         }
  31.                 }
  32.  
  33.                 if (clipping == UIDrawCall.Clipping.SoftClip)
  34.                 {
  35.                         minArea.x += clipSoftness.x;
  36.                         minArea.y += clipSoftness.y;
  37.                         maxArea.x -= clipSoftness.x;
  38.                         maxArea.y -= clipSoftness.y;
  39.                 }
  40.  
  41.  
  42.                 return NGUIMath.ConstrainRect(minRect, maxRect, minArea, maxArea);
  43.         }
  44.  

then in UIScrollView, add "true" as a paramater to both the "CalculateConstrainOffset" method calls, ie:

  1. Vector3 constraint = mPanel.CalculateConstrainOffset(bounds.min, bounds.max);
  2. //becomes
  3. Vector3 constraint = mPanel.CalculateConstrainOffset(bounds.min, bounds.max, true);

Things to be aware of:

Only tested to on UIScrollView that scroll vertically and snap to the top.
Expects a UIGrid child which contains a vertical grid of items of the same height.

15
thanks ill have a look tomorrow at work and get back to you!

Pages: [1] 2