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 - ryan

Pages: 1 [2] 3 4 ... 6
16
NGUI 3 Support / UIScrollView optimization
« on: February 18, 2014, 05:02:55 PM »
I have a use case where UIScrollView.LateUpdate is taking about 20ms to run on an iPad 2.  Part of the problem is that I have way too many widgets in the scroll view, but the other part is that one of its children has a pulsing color, causing UIScrollView to recalculate the bounds of its children every frame.  It's deciding whether to change the alpha on the scroll bars, but there are no scroll bars.  I've locally changed this line near the top of LateUpdate:

      if (showScrollBars != ShowCondition.Always)

to this:

      if (showScrollBars != ShowCondition.Always && (verticalScrollBar || horizontalScrollBar))

I can also change showScrollBars to Always on my prefab, but that's too easy.

17
NGUI 3 Support / Re: HELP: Propagate dimension changes to children
« on: February 18, 2014, 04:43:17 PM »
If the parent is also a widget, there's an onChange callback that you can register.

18
NGUI 3 Support / Re: UIPanel depth behavior is frustrating.
« on: February 11, 2014, 01:27:45 PM »
If you want something to draw on top of the scroll view, you need another panel with a higher depth.  So you'll have three panels: one for whatever draws behind the scroll view, one for the scroll view, and one for stuff in front of the scroll view.

19
NGUI 3 Support / Re: NGUI3.0.5 confuses perforce source control
« on: January 30, 2014, 01:50:25 PM »
Oh yeah, same here.  I still see the Physics settings getting checked out every once in a while, but that's probably one of our import tools or something.  Certainly not NGUI-related.  Thanks, Michael!

20
NGUI 3 Support / Re: (!!!) Improving NGUI: Voice your opinion
« on: January 29, 2014, 04:26:35 PM »
Motion is a very important part of UIs for me, having the ability to define a group of tweens such as transition in / out and being able to call them would be a great core feature.

+1 to that.  I have a hard time deciding whether or not to have UI artists put tweens into the UI prefabs, for fear that an engineer will tween something from code, overwriting what the artists put in.

21
This essentially is a UV issue.  As characters are added to the dynamically generated texture, Unity will occasionally need to rebuild the entire texture to make room for more characters.  It may make the texture bigger, or it may remove unused characters, but in either case the UVs of each individual character are changing.

Unity provides an API to notify applications when this rebuild is happening, and NGUI listens to those events and flags affected labels to be rebuilt the next time UIPanel's LateUpdate is run.  However, if you manage to instantiate some UILabels or otherwise cause new characters to be rendered for a dynamic font after UIPanel.LateUpdate, but before the end of the frame, then NGUI doesn't have a chance to respond until the next frame.  We've run into this problem once or twice.  It becomes especially apparent when doing blocking operations that cause a long delay between frames.  You don't notice this in the editor because (I think) the editor keeps the dynamic texture around between invocations of your code, so it's likely already sized large enough that a rebuild isn't necessary.

In our case, we were instantiating some UI prefabs while handling a network response from a coroutine.  Somehow the Start function was being called on those instances after UIPanel.LateUpdate but still in the same frame.  We managed to work around it by having the coroutine set a flag that we waited until the next Update to act on, so our prefabs were instantiated at a different time.  Michael might be able to address this in NGUI somehow, but it's probably not trivial to rebuild all of the affected panels outside of LateUpdate.

22
NGUI 3 Support / Re: [Feature Request / S] Expose sorting delegates
« on: January 23, 2014, 01:53:19 PM »
It would be good if custom editors would work for child classes, wouldn't it?

Unfortunately that's something you should tell Unity, as that has nothing to do with NGUI. :)

Apparently somebody did tell them?  http://docs.unity3d.com/Documentation/ScriptReference/CustomEditor-ctor.html  I'm not sure when they added that second parameter, but it looks like it would do the right thing.

23
NGUI 3 Support / Re: NGUI3.0.5 confuses perforce source control
« on: January 13, 2014, 08:28:06 PM »
We've seen this, too.  Nothing actually changes in either the prefab or the meta file, they're just checked out of perforce.  (We've always had metadata serialization set to force text.)  For us, it usually happens after playing the game in the editor.  Just opening unity, saving, and quitting generally doesn't trigger it.  It's not strictly limited to NGUI prefabs, either, though they are the majority of affected files.  Occasionally something else like Physics2DSettings.asset will get checked out with no changes.

I personally usually check files in using P4V, even when they were checked out through Unity, so maybe Unity has some bad state cached and thinks those files are supposed to be checked out?  We've just been living with it here and reverting the checkouts when it happens.

24
NGUI 3 Support / Re: (!!!) Improving NGUI: Voice your opinion
« on: January 09, 2014, 02:27:39 PM »
I'm also pretty excited about the new anchoring system, but it seems like you have to be careful not to go overboard with using them.  I did some profiling on an iPad 2 the other day, and on a screen that contained ~300 anchored widgets, it was spending a few milliseconds per frame in UIRect.Update.  None of the widgets were changing, but the overhead of checking the anchors (and yes, some overhead from the profiler) were taking a lot more time than expected.

I ended up removing most of the anchors, as they weren't entirely necessary for what I needed.  I had put them in so that everything would adjust correctly if a parent widget were resized, but in this case we weren't ever doing that at runtime.  I'm wondering if something could be implemented where changes to an anchor's target actively trigger an update down through the dependent UIRects, rather than everything passively reacting to target changes.  I guess there's a memory trade-off there to track the dependent anchors, but it might be something I end up implementing separately from NGUI if I have time later on.

25
NGUI 3 Support / UIInput bugs in 3.0.8f3
« on: December 31, 2013, 04:15:34 PM »
If I open and run the Tutorial 9 scene from the examples, click the input and type in some characters, then use the left arrow key multiple times to move the carat back, it only moves one character before getting stuck.  It looks like it's actually adding some invisible characters to the string, as I see some odd artifacts in the inspector which also become visible in the game window if I switch to a dynamic font.

Possibly related, when running in the editor on Mac, cmd-x/cmd-c/cmd-v to cut/copy/paste are also inserting an x, c, or v character.  This only happens in the editor, not when building and running the app, so I consider it a minor issue.  I ran into this a while back with a separate product, and I think it was actually a unity problem where the editor wasn't reporting events properly when the command key was involved, but maybe there's something you can do about that.

26
NGUI 3 Support / Re: (!!!) Improving NGUI: Voice your opinion
« on: December 13, 2013, 07:54:40 PM »
I would love an event that we could hook into to be notified when a widget or rect's size and position have changed.  The new anchor system is great for making UI's the fit whatever screen dimensions you've got, but I have several cases where I want to do something more complicated within a particular region of the UI based on the space available.  This is stuff that I don't want to recalculate every frame, and I'd rather not have to poll to see if the widget has changed, either.

Maybe there's a more general solution that can work with the new anchor system to allow more powerful layouts to be created...

27
NGUI 3 Support / Weird culling of nested widgets in clipped panels
« on: December 13, 2013, 01:59:58 PM »
Now that we're allowed to nest widgets inside other widgets, I've started using that with the new anchor system to lay things out.  I've noticed when using a scroll view with soft clipping (probably any clipping) that once a parent sprite is no longer visible inside the scroll view, any of its children will suddenly disappear, even if they extend outside the bounds of the parent.  This is most obvious if I've used a 2x2 empty widget to anchor the position of a group of widgets, but happens in other cases, too.  (For now I've made those empty widgets encompass the bounds of their children, so I've got a workaround, but thought I'd mention the problem.)

For an example, open up the example scroll view scene with the soft clipped panel.  In one of the items in the scroll view, make the orc armor sprite a child of the sliced sprite, and drag it over so its center is on the left or right edge of the sliced sprite.  Make the "New!" label a child of the orc armor and place its horizontal center on the edge of the sprite.  Now press play and drag the scroll view so that the sliced sprite is outside the clip rect.  You should see the orc armor and the text disappear immediately (except when actively moving the scroll view).

28
NGUI 3 Support / Re: NullReferenceException in UIRect.GetLocalPos
« on: December 11, 2013, 02:02:29 PM »
I can't wait until the next frame.  I'm instantiating a bunch of prefabs into the panel right after I adjust the anchors, and the size and position of those prefabs changes based on the clip rect of the panel.  (Think buttons that change in height down to a minimum size, then go from two rows of buttons to one if two rows don't fit.)  OK, technically I could wait until the next frame to instantiate my prefabs, but I'd rather not.  But it sounds like UpdateAnchors would be the right thing to call in that case, and that you've fixed the bug in some other way, so thanks!

29
NGUI 3 Support / Re: NullReferenceException in UIRect.GetLocalPos
« on: December 10, 2013, 07:11:31 PM »
Related problem:  GetViewSize is giving me bad results on retina iPads.  My UIRoot is set to fixed size with a manual height of 768.  However, it looks like the panel isn't finding the UIRoot in UIRect.OnEnable.  I added a check in UIPanel's OnStart to attempt to discover the root again if it's still null, but that's just a quick workaround.

30
NGUI 3 Support / NullReferenceException in UIRect.GetLocalPos
« on: December 10, 2013, 04:25:22 PM »
I may be doing something wrong or using the new anchor system in an unintended way, but…

I have a prefab containing a UIPanel with soft clipping anchored to a parent transform, basically set up to fill the screen minus some padding.  In the Start method of a component of mine in the prefab, I'm modifying the anchor's absolute values based on some other state, then calling UpdateAnchors on the panel so that GetViewSize will return the correct value:

  1. scrollView.panel.bottomAnchor.absolute += footerPadding;
  2. scrollView.panel.UpdateAnchors();

This causes the following exception:

  1. NullReferenceException: Object reference not set to an instance of an object
  2. UIRect.GetLocalPos (.AnchorPoint ac, UnityEngine.Transform trans) (at Assets/Plugins/Client/NGUI/Scripts/Internal/UIRect.cs:212)
  3. UIPanel.OnAnchor () (at Assets/Plugins/Client/NGUI/Scripts/UI/UIPanel.cs:758)
  4. UIRect.UpdateAnchors () (at Assets/Plugins/Client/NGUI/Scripts/Internal/UIRect.cs:309)
  5. MyClass.Start () (at Assets/Scripts/.../MyClass.cs:344)
  6.  

I was able to fix the error by modifying UpdateAnchors in UIRect:

  1.         public void UpdateAnchors ()
  2.         {
  3.                 if (!mAnchorsCached) CacheAnchors();
  4.                 if (isAnchored) OnAnchor();
  5.         }
  6.  

I'm not sure if this is the best fix, or if I should be calling something else from my code to get things to recalculate.  I need to be able to get the correct size of the scroll view later in my Start method to be able to correctly size and position some other elements.

Pages: 1 [2] 3 4 ... 6