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

Pages: [1] 2 3 4
1
NGUI 3 Support / Re: Change Request UIInput.cs
« on: September 24, 2013, 10:35:52 AM »
I am interested in the same suggestion. It makes sense to me that all events happen on the selected event receiver. The argument that OnInputChanged is mainly for input validation doesn't make sense since there is the validator delegate to do that. I have made the change to our project, but it would be nice to have it a permanent change.

2
NGUI 3 Support / Re: UILabel Shrink to Fit width no longer works
« on: September 17, 2013, 09:45:56 AM »
I now understand that the full answer to this issue is that BOTH the width and height need to be specified WITH 0 FOR MAX LINES, AND the Shrink To Fit checkbox on. If any one of these things isn't true, the whole thing doesn't work. So, I guess I'll just start filling in height values. I noticed that if I use the scale value of the font, it means the height of 1 line.

3
NGUI 3 Support / Re: UILabel Shrink to Fit width no longer works
« on: September 17, 2013, 07:45:41 AM »
Set max lines to 0 if you want the old shrinking behaviour.

Actually, no, this doesn't work, and wouldn't be a feasible solution anyway. Most of the time when I want to shrink to fit width, I want it only on one or two lines. Setting max lines to 0 implies no line limit, which conflicts with shrinking vs. wrapping.

Please see screenshots.

4
NGUI 3 Support / Re: UILabel Shrink to Fit width no longer works
« on: September 16, 2013, 04:03:56 PM »
I eagerly await feedback on this from ArenMook, since it's breaking my UI's at the moment.

On a similar topic, how hard would it be to apply line spacing for UILabels ?

5
NGUI 3 Support / new depth sorting feature
« on: September 16, 2013, 01:08:13 PM »
I tried out the new depth sorting feature to understand how it was different. I was hoping that it would make it so UIPanel would automatically detect when a new draw call was necessary, and make the draw calls as needed, even if it meant drawing from the same atlas multiple times due to a different atlas being used in between the sort order.

Sometimes you need to have text in front of and behind sprites from the same atlas, and the font is on a different atlas. That requires three draw calls total. It appears that I still need to add another UIPanel for the foreground stuff and set the z coord a little closer to be in front of the other stuff.

6
NGUI 3 Support / UILabel Shrink to Fit width no longer works
« on: September 16, 2013, 10:04:21 AM »
We just updated our NGUI, and I noticed that UILabel now has an option to shrink to fit height. However, the shrink to fit width no longer works. All it does it cut off the text instead of shrinking it. Now only reducing the "Max Height" actually shrinks the text.

Also, I would really like it if the shrinking ignored the new height option if Max Height is set to 0, mainly for backwards compatibility.

7
NGUI 3 Support / Re: extra UIPanel being created
« on: August 21, 2013, 06:55:17 AM »
I guess there is more than one way NGUI can to get to adding the UIPanel under this situation, but to answer your question here is the stack trace from UISprite.MakePixelPerfect():

UIPanel:Find(Transform, Boolean) (at Assets/Code/Libraries/NGUI/Scripts/UI/UIPanel.cs:1279)
UIPanel:Find(Transform) (at Assets/Code/Libraries/NGUI/Scripts/UI/UIPanel.cs:1290)
UIWidget:CreatePanel() (at Assets/Code/Libraries/NGUI/Scripts/Internal/UIWidget.cs:348)
UIWidget:set_material(Material) (at Assets/Code/Libraries/NGUI/Scripts/Internal/UIWidget.cs:201)
UISprite:GetAtlasSprite() (at Assets/Code/Libraries/NGUI/Scripts/UI/UISprite.cs:343)
UISprite:get_isValid() (at Assets/Code/Libraries/NGUI/Scripts/UI/UISprite.cs:155)
UISprite:MakePixelPerfect() (at Assets/Code/Libraries/NGUI/Scripts/UI/UISprite.cs:414)

8
NGUI 3 Support / Re: extra UIPanel being created
« on: August 20, 2013, 11:31:29 AM »
I'm not sure you understood the description of the original problem, which appears to be a Unity bug.

I have the "UI Root (2D)" standard NGUI hierarchy in my scene. There is a UIPanel in there that I want to drag a prefab onto. The prefab consists of NGUI elements, including sprites and UIImageButtons, but doesn't have a UIPanel at its root because I plan on using the on already in the scene's hierarchy. However, when dragging the prefab onto the existing UIPanel object, the new object (from the prefab) ends up with another UIPanel on it. After some investigation, here's what's happening.

1. The new object is instantiated at the root of the project by Unity.
2. The OnEnable() function is called in UIImageButton.
3. UIImageButton makes a call to MakePixelPerfect().
4. MakePixelPerfect looks for the rendering UIPanel for sprites on the UIImageButton.
5. Since the new object is in the root, it doesn't find a UIPanel and creates one.
6. Eventually, Unity moves the new object to the final place in the hierarchy (the object you dropped the prefab onto).
7. Now your object has a UIPanel on it even though it's under another UIPanel.

9
NGUI 3 Support / extra UIPanel being created
« on: August 18, 2013, 12:27:20 PM »
I've been running into a situation where when I drag a prefab of NGUI stuff into my NGUI hierarchy in the scene, it always ends up with a UIPanel on it when it shouldn't. I dug into it and found that there must be a Unity bug that temporarily puts the new scene object at the root, which is when the OnEnable of UIImageButton is fired off, THEN gets moved to the final place in the hierarchy. NGUI always thinks there is no UIPanel rendering this new thing since it checks while the object is at the root of the project. I have reported this bug to Unity, but in the meantime I have also made these changes to UIImageButton, which seems to help as well.

Basically, in the OnEnable() function, I pass false to the UpdateImage() function, telling it not to do a MakePixelPerfect(), since that is what triggers creating the UIPanel. I don't think it's necessary to call MakePixelPerfect() during OnEnable() anyway.

  1.         void OnEnable () { UpdateImage(false); }        // Gillissie added false argument.
  2.        
  3.         void UpdateImage(bool makePixelPerfect = true)  // Gillissie added makePixelPerfect argument.
  4.         {
  5.                 if (target != null)
  6.                 {
  7.                         if (isEnabled)
  8.                         {
  9.                                 target.spriteName = UICamera.IsHighlighted(gameObject) ? hoverSprite : normalSprite;
  10.                         }
  11.                         else
  12.                         {
  13.                                 target.spriteName = disabledSprite;
  14.                         }
  15.                         if (makePixelPerfect)
  16.                         {
  17.                                 // Gillissie - Added this condition, since calling this when dragging a prefab
  18.                                 // into the scene in the editor causes a UIPanel to be added unnecessarily,
  19.                                 // due to a bug in Unity where the OnEnable() function is called on objects
  20.                                 // before they reach their final place in the hierarchy, so NGUI doesn't find
  21.                                 // the UIPanel when first being activated.
  22.                                 target.MakePixelPerfect();
  23.                         }
  24.                 }
  25.         }
  26.  

10
NGUI 3 Support / Re: Radial menu
« on: August 14, 2013, 05:18:18 PM »
You can also let Unity's Transform objects do the calculations for you. Just create an empty object, then child objects that are spaced out around the parent object in a circular pattern. The position of each of those child objects is where you can position your menu items.

11
NGUI 3 Support / swiping/dragging detection on particular objects
« on: August 14, 2013, 05:15:08 PM »
I have multiple areas in my mobile UI that will require a swipe to go to the next page of stuff. For this reason, I need to be able to know which area was touched when the swipe happened, so only that area changes pages. I am having a hard time understanding how to detect this information with NGUI.

For each swipable area, I have created a box collider.

I've tried looking at UICamera.currentTouch, but I can't figure out how or when that is populated with data I need. I don't know if NGUI has any kind of built-in support for drag events on particular objects, without the actual dragging of the object (the collider shouldn't move - it only needs to detect the touch, and the distance moved while touching).

On other non-NGUI projects that I've done this kind of thing, it was easy to store which object was touched, and the mouse location of the original touch, and compare it to the current mouse location to get the drag distance, and have certain things react only if certain objects were initially touched.

Thanks!

12
NGUI 3 Support / Re: Bug with UILabel "adjust scale to fit"
« on: August 12, 2013, 05:54:38 PM »
It's where the code with this comment is:

  1. if (mShrinkToFit)
  2. {
  3.         // We want to shrink the label (when it doesn't fit)
  4.         mSize.x /= mFont.pixelSize;     // Gillissie added
  5.  

13
NGUI 3 Support / Re: Bug with UILabel "adjust scale to fit"
« on: August 12, 2013, 07:46:07 AM »
On a related note, I have also changed line 652 of UILabel to take the font's pixel size into account when doing the effects...

old
float pixel =  1f / mFont.size;

new:
float pixel =  1f / mFont.size / mFont.pixelSize;

It would be great to see these changes in future versions out of the box. Thanks.

14
NGUI 3 Support / Re: Bug with UILabel "adjust scale to fit"
« on: August 12, 2013, 07:41:10 AM »
Changing lines of UILabel seems to have fixed it:

line 494
old:
float maxY = mFont.size * mMaxLineCount;

new:
float maxY = mFont.size * mMaxLineCount * mFont.pixelSize;

Add this line right after "if (mShrinkToFit)":
mSize.x /= mFont.pixelSize;

Also, this helps in the font setter, after everything else. Most other property setters have this call, so I'm not sure why the font setter doesn't:
if (shrinkToFit) MakePixelPerfect();

15
NGUI 3 Support / Bug with UILabel "adjust scale to fit"
« on: August 12, 2013, 07:27:38 AM »
I am setting up my game so that there are two different sizes of each font, and using a reference font that gets set to one of the sizes, depending on what resolution the game is being run in (on a mobile device).

This works great, except that the "adjust scale to fit" feature seems to ignore the pixel size value of the current font. It seems to scale the label based on a pixel size of 1, no matter what it is set to.

Pages: [1] 2 3 4