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 5 6
NGUI 3 Support / UIAtlasMaker public API
« on: November 12, 2013, 06:16:29 PM »
Would you mind exposing more of the atlas maker's functionality?  I'm trying to automate updating all of the sprites in an atlas from a directory containing the textures, and it's really slow doing it one at a time, and I can't remove sprites with what's currently public.  I'm looking for something along these lines:

  1.         public static void UpdateAtlas(UIAtlas atlas, List<Texture> textures, bool keepSprites)
  2.         {
  3.                 if (atlas != null && textures != null)
  4.                 {
  5.                         List<SpriteEntry> sprites = CreateSprites(textures);
  6.                         ExtractSprites(atlas, sprites);
  7.                         if (!keepSprites)
  8.                         {
  9.                                 sprites.RemoveAll((se) => (textures.Find((t) => == == null));
  10.                         }
  11.                         UpdateAtlas(atlas, sprites);
  12.                 }
  13.         }

Scale z along with x and y:

transform.localScale = new Vector3(0.8f, 0.8f, 0.8f)

NGUI 3 Support / Re: Reduce garbage collection
« on: November 04, 2013, 01:32:53 PM »
If I'm not mistaken, you can also just zero out the extra elements in your buffer and nothing will be drawn.

NGUI 3 Support / Re: UICamera's touch API
« on: November 04, 2013, 01:20:06 PM »
I thought that was true at one point, and I see that ProcessMouse uses negative touch IDs, but it also goes directly to mMouse instead of calling GetTouch.  I don't see where the mouse inputs would ever end up in mTouches, and GetTouch never looks at mMouse.

NGUI 3 Support / UICamera's touch API
« on: October 30, 2013, 02:09:38 PM »
I'm trying to integrate a project's input processing with the work NGUI's already doing in UICamera.  In the past, I've had a separate class that looks at Unity's Input.touches and just does a raycast to see if it's a UI touch and ignores it, but this seems wasteful since I should just be able to ask UICamera.  I see onCustomInput as a handy place to hook in after UICamera has done its work, but getting access to its MouseOrTouch instances is a little wonky.

There's no public access to the mMouse, so if I want to know if a mouse click was on a UI object, I have to figure it out myself.  This is in spite of the fact that mMouse is included in the calculations for touchCount and dragCount.  I do have access to the touches through GetTouch, but this potentially dirties the list of touches if I ask for a touch ID that has been removed.  Also, if I want to account for controller input, onCustomInput is called between mouse/touch processing and controller processing, so that could be problematic.

Of course I can make changes, but for now I'm trying to avoid any custom changes to NGUI to make updating easier.  Am I over-thinking/over-complicating things?  Is there an easier way to go about deciding whether or not to process a touch?

NGUI 3 Support / Re: bug in UIInput
« on: April 04, 2013, 11:59:46 PM »
So does the existing code just above where that's added.  :P

NGUI 3 Support / Re: bug in UIInput
« on: April 03, 2013, 10:35:37 PM »
  1. diff NGUI-2.5.1/Assets/NGUI/Scripts/UI/UIInput.cs Project/Assets/NGUI/Scripts/UI/UIInput.cs
  2. 468c468,483
  3. <
  4. ---
  5. >                                       else if (mPivot == UIWidget.Pivot.Center)
  6. >                                       {
  7. >                                               label.pivot = UIWidget.Pivot.Right;
  8. >                                               pos.x -= label.lineWidth * 0.5f;
  9. >                                       }
  10. >                                       else if (mPivot == UIWidget.Pivot.Top)
  11. >                                       {
  12. >                                               label.pivot = UIWidget.Pivot.TopRight;
  13. >                                               pos.x -= label.lineWidth * 0.5f;
  14. >                                       }
  15. >                                       else if (mPivot == UIWidget.Pivot.Bottom)
  16. >                                       {
  17. >                                               label.pivot = UIWidget.Pivot.BottomRight;
  18. >                                               pos.x -= label.lineWidth * 0.5f;
  19. >                                       }

I realized after making this change that right-aligned labels aren't supported either, or I probably would have made this slightly more elegant.  Silly me.  Left that as an exercise for the reader.

NGUI 3 Support / Re: Can Ngui labels have a gradient fill?
« on: February 24, 2013, 02:55:53 AM »
You can modify the font bitmap using Photoshop or some other tool to put the gradient in, but there's nothing built into NGUI to do it for you.

NGUI 3 Support / Re: NGUI is great.... almost
« on: February 11, 2013, 04:54:11 PM »
I know Michael has commented on the lack of access to the system's copy/paste buffer in the past, which is definitely a hindrance, but I think the other three features listed would be a big plus on PC/Mac, and should be possible.  Fortunately it's less of an issue on iOS, where the native keyboard popup handles that functionality for you.

So I've got a draggable panel with a scrollbar, and the panel is set to only show the scrollbar when dragging.  That works great, but if I use the scroll wheel, this doesn't make the scrollbar visible like I would expect from a native Mac app.  I changed line 603 of UIDraggablePanel from this:

  1. if (showScrollBars != ShowCondition.WhenDragging || mDragID != -10)

to this:

  1. if (showScrollBars != ShowCondition.WhenDragging || mDragID != -10 || mMomentum.magnitude > 0.01f)

which makes the scrollbar visible while using the scroll wheel, and has the added benefit of leaving it visible after a drag while momentum is still being applied.  That threshold could maybe be tuned a little bit.  I started with 0.0001f as is used a few lines further down in the class, but that left the bar showing for a bit too long.  Any chance this, or a similar change, could be incorporated?

NGUI 3 Support / Re: Font kerning not serialized?
« on: January 11, 2013, 09:35:10 PM »
The effects are mostly not noticeable, but with our font certain character combinations ended up a little more crowded than they should have been.  A lowercase "f" followed by an apostrophe is what caused me to investigate.  In the attached example, the spacing between the capital "W" and lowercase "i" is also slightly different, and a little extra space is inserted before the capital "T" without kerning.

Thanks for the modification.

NGUI 3 Support / Font kerning not serialized?
« on: January 11, 2013, 03:24:02 PM »
Looking into a problem with some font spacing today, I noticed that my font prefabs don't have any of the kerning information serialized.  After a little digging, I found that the kerning is stored in a struct, and apparently Unity doesn't support serialization of user-defined structs.  I did this to get the kerning serialized:

  1. diff old/Assets/NGUI/Scripts/Internal/BMGlyph.cs new/Assets/NGUI/Scripts/Internal/BMGlyph.cs
  2. 16c16,17
  3. <       public struct Kerning
  4. ---
  5. >       [System.Serializable]
  6. >       public class Kerning
  7. 67,69c68
  8. <                               Kerning k = kerning[i];
  9. <                               k.amount = amount;
  10. <                               kerning[i] = k;
  11. ---
  12. >                               kerning[i].amount = amount;

NGUI 3 Support / Re: Dynamic font support for NGUI
« on: January 08, 2013, 12:29:46 PM »
So... all the dynamic font solutions (this is what, 3rd one in 2 days now? :)) are limited by the same clause -- that is the font must be in a separate texture and can't be using the atlas texture, right?

For what it's worth, that doesn't bother me at all.  We have some atlases that are big enough already that trying to squeeze a font into it, even a dynamic one, would be tricky.  I split our font out into its own atlas long ago in anticipation of something like this feature for when we localize.  Limiting draw calls is all well and good, but getting hung up on the whole single draw call thing and passing over this feature because it doesn't achieve that would be a mistake.  (Not that you've said you're passing on it.)

NGUI 3 Support / Re: Null pointers in BetterList and UIPanel
« on: December 16, 2012, 02:49:55 AM »
Not intentionally, but I think that's pretty much what was happening.  I'm a little hazy on the details, because somebody else was working on fixing it, but I think the problem on our side was that we had class A asking class B to destroy a portion of the UI, and then class A proceeded to unload the bundle containing that UI, while class B was waiting until the next Update to actually destroy the UI.  This probably also involves that other bug I mentioned a while ago about OnDestroy not getting called on objects that are destroyed as a result of their bundle being unloaded.

NGUI 3 Support / Null pointers in BetterList and UIPanel
« on: December 14, 2012, 08:36:59 PM »
We're in the middle of debugging an issue here that I think is related to unloading some bundles, which has exposed some NullReferenceExceptions in BetterList.Contains and UIPanel.GetDrawCall:

  1. NullReferenceException: Object reference not set to an instance of an object
  2.   at BetterList`1[UnityEngine.Material].Contains (UnityEngine.Material item) [0x00000] in <filename unknown>:0
  3.   at UIPanel.UpdateTransforms () [0x00000] in <filename unknown>:0
  4.   at UIPanel.LateUpdate () [0x00000] in <filename unknown>:0
  6. NullReferenceException: Object reference not set to an instance of an object
  7.   at UIPanel.GetDrawCall (UnityEngine.Material mat, Boolean createIfMissing) [0x00000] in <filename unknown>:0
  8.   at UIPanel.Fill (UnityEngine.Material mat) [0x00000] in <filename unknown>:0
  9.   at UIPanel.LateUpdate () [0x00000] in <filename unknown>:0

The BetterList error should be easy to fix:

  1. for (int i = 0; i < size; ++i) if (buffer[i] != null && buffer[i].Equals(item)) return true;
  3. instead of
  5. for (int i = 0; i < size; ++i) if (buffer[i].Equals(item)) return true;

Unfortunately no line numbers are available in the builds we've seen this in, but I think a null material is sneaking in somewhere when we unload some bundles containing our UI, so UIPanel.GetDrawCall is probably failing on:

  1. GameObject go = new GameObject("_UIDrawCall [" + + "]");

Whether or not that should be fixed, or how best to fix it without a reliable repro, I'll leave up to you.  That specific error is easy enough to guard against, but if UIDrawCall instances are left hanging around with null materials, that's obviously a bad state that we shouldn't be letting NGUI get into.  We're working on fixing the source of the problem in our code, but I figured these were worth pointing out in case you wanted to deal with them.

Pages: 1 2 [3] 4 5 6