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

Pages: [1] 2
1
Welp, figured it out. Now I feel dumb. In case anyone stumbles on this, the issue is that PrintExactCharacterPositions needs the processedText (so that it has the newline characters), which makes sense. However, the vertex buffers it outputs don't include entries for the newline character, which also makes sense in retrospect. So, if you're crawling a string/tokens like I am and tracking your current index, you need to ignore any newlines when calculating your vertex buffer idx. Everything now lines up perfectly regardless of alignment/pivot/line number.

2
Oh, and to answer your other question, no, changing pivot or alignment has no effect on the offset. No matter what combination of the two the sprite always renders in the same (slightly wrong) position based on which line of the multiline label it is.

3
Actually, looking into making a custom NGUIText.Print might be a good way to go. Thanks for the suggestion. I'll look into that this weekend.

4
NGUI 3 Support / Re: UILabel ColorTint overriding inline color?
« on: June 25, 2016, 04:24:15 PM »
Found the actual bug. It's in NGUIText.cs:

ParseSymbol is failing to set ignoreColor to true when it detects a 24 or 32bit color symbol, and likewise is not setting it to false when it encounters a [-] symbol. Not sure those are the only places its not setting things correctly, but making those 3 changes got things working for my purposes.

5
NGUI 3 Support / UILabel ColorTint overriding inline color?
« on: June 25, 2016, 03:59:20 PM »
There seems to be a change (not sure exactly when as I upgraded from a much earlier v3 version to 3.9) that I think is a bug in how UILabel inline color works. Previously, if you set inline color, it would override the global colortint of the label widget. Now the colorTint seems to be multiplied into the inline color. So if my text is set to be black by default, I now can't actually use inline colors as it still multiplies to black. Pretty easy to repro, just make a label and try to have the default text be black and set a word to red using inline coloring.

6
I'm calling UpdateNGUIText in the first line of what I pasted (though it looks like the indenting is wrong on the first line so I can see how you missed that).

Also, I believe I am correctly accounting for alignment by how I am using targetLabel.pivotOffset (I assign that to my "offset" var and use that in my positioning later in the pasted code).

7
So I'm working on a relatively complex label hack to allow me to encode input data, then hide it and display a rendered sprite of the input in question over top. I have it working (finally), but I ran into a really weird bug, or at least what seems like a bug. While using PrintExactCharacterPositions I got great results so long as the label was a single line. As soon as wrapping occurs however I'm finding my verts are off in their X position by some multiple of how many lines from the top of the label they are. To put another way, the verts array for the first line is perfect, second line is off in X by 1*n, 3rd is off by 2*n, and on like that.

Its a pretty hard to show what's going on, hence the lack of images. Here is a section of the code that may be relevant (I've stripped a bunch of stuff out of the actual function that isn't relevant to the NGUI side, so if it looks a bit out of context that's why):

  1. targetLabel.UpdateNGUIText();
  2.         lastText = NGUIText.StripSymbols(targetLabel.processedText);
  3.  
  4.         string textSoFar = "";
  5.         Vector2 offset = targetLabel.pivotOffset;
  6.  
  7.         BetterList<Vector3> verts = new BetterList<Vector3>();
  8.         BetterList<int> indicies = new BetterList<int>();
  9.  
  10.         NGUIText.Update();
  11.         NGUIText.PrintApproximateCharacterPositions(targetLabel.processedText, verts, indicies);
  12.  
  13.         Vector2 characterSize = NGUIText.CalculatePrintedSize("O");
  14.         Bounds b = targetLabel.CalculateBounds();
  15.  
  16.         string[] tokens = lastText.Split(new char[] {' ', '\n'}, System.StringSplitOptions.None);
  17.         int idx = 0;
  18.         foreach(string tok in tokens) {
  19.                 if (tok.StartsWith("$i:")) {
  20.  
  21.                         Vector3 vertA = verts[(textSoFar.Length) * 2];
  22.                         Vector3 vertB = verts[(textSoFar.Length + tok.Length) * 2 - 1];
  23.  
  24.                         int defIdx = int.Parse(tok.Substring(3).Replace("@", ""));
  25.                         UiManager.InputSpriteEntry ie = GameManager.uiManager.inputSpriteDefs[defIdx];
  26.  
  27.                         UISprite sprite = NGUITools.AddSprite(targetLabel.gameObject, GameManager.uiManager.defaultAtlas, ie.sprite);
  28.  
  29.                         sprite.depth = 200;
  30.                         sprite.MakePixelPerfect();
  31.                         sprite.keepAspectRatio = UIWidget.AspectRatioSource.BasedOnHeight;
  32.                         sprite.height = fixedSize ? (int)scaleFactor : (int)(characterSize.y * scaleFactor);
  33.                         if (forceCenter) {
  34.                                 sprite.transform.localPosition = Vector3.zero;
  35.                         } else {
  36.                                 Vector3 pos = (vertA + vertB) * 0.5f;
  37.                                 pos.x -= offset.x * b.size.x ;
  38.                                 pos.y += (1f - offset.y) * b.size.y;
  39.                                 sprite.transform.localPosition = pos;
  40.                         }
  41.                 }
  42.                 if (idx == tokens.Length - 1) {
  43.                         textSoFar = string.Format("{0}{1}", textSoFar, tok);
  44.                 } else {
  45.                         textSoFar = string.Format("{0}{1}{2}", textSoFar, tok, lastText[textSoFar.Length + tok.Length]);
  46.                 }
  47.                 idx++;         
  48.         }
  49. }
  50.  

Oddly, PrintApproximateCharacterPositions seems more accurate for multiline labels, so I'm using that for now as the overall error is lower, but would be awesome to get Exact working. Any ideas  more than welcome.

8
NGUI 3 Support / Re: UICheckbox Not Checking (Visually)
« on: February 01, 2013, 09:09:26 AM »
Confirmed 4.1 issue. Specifically, it's the function HasChanged() in UINode.cs. The new 4.1 optimizations (line 90-94) cause the issue, and if you comment them out (along with the #if #else) and use the old Unity 3/4 code instead, it works fine again in 4.1. Also, fyi, in my 4.0.1 install that code errors out because it tries to use the 4.1 code instead of the 4.0 code. I assume UNITY_4_0 is false for 4.0.1, but I'm not sure.

-Sean

9
NGUI 3 Support / UICheckbox Not Checking (Visually)
« on: February 01, 2013, 08:15:10 AM »
I have started seeing an issue with UICheckbox that I don't remember seeing before the last update, but I could be crazy. If I set a UIPanel to active with the checkbox unchecked, and then click the checkbox, the image never updates. I believe it is actually a problem with the draw-call batcher, as if I pause the scene and look at the check-sprite, it is enabled and it's alpha has been turned back on. In addition, if I SetActive false on the panel and then immediately SetActive true, the check will show up. Oddly, it works fine if I activate the panel with the check enabled. I can then uncheck and recheck it without issue until I hide the panel again with it unchecked.

So, to summarize repro steps:

UICheckbox living under a UIPanel
uncheck the checkbox, then NGUITools.SetActive(panel, false)
next, SetActive true to show the UI, and then try to check the box. Clicking it will change the state (and the alpha tween works as well, if you watch the sprite in the inspector), but it never actually draws until you setactive false and then true again.

Currently happening in 4.1, I'll dig up my 4.0.1 laptop and give it a shot there to see if its maybe a new unity issue, and update the post when I find out.

-Sean

10
NGUI 3 Support / Re: Sudden UIPanel Problems (clipping and dragable)
« on: January 14, 2013, 02:07:29 AM »
I can see not clamping local to itself, but it seems like it should be local to its parent, or at least the UICamera. Also, regardless of the locality, it isn't behaving as expected. I had a top-node rotated (0, 90, 0), a few other nodes (0,0,0), then the UICamera, Anchor and Parent Panel and finally the panel in question, all (0,0,0). The draggable Scale is (0,1,0), so regardless of locality, it should only be allowing dragging in 1 axis, but it ends up allowing it in X and Y (relative to camera).

Anyway, I have it working now either way, but just wanted to mention that part in case that isn't expected.

11
NGUI 3 Support / Re: Sudden UIPanel Problems (clipping and dragable)
« on: January 12, 2013, 09:55:05 PM »
Ok, I figured it out. My ultimate parent object had a 90 degree rotation in Y. This seems to completely confuse the way the scale value clamps the movement. clamping it later in the process might actually fix it (I took a quick look at the code, and it clamps, but then gets TransformDirection applied a few times before and during the MoveAbsolute and MoveRelative functions, which ends up unclamping it essentially). Either way, it's working for me now, since I just un-rotated the parent object, but might be worth re-working the clamping code so it works in local-space regardless of parent rotations.

-Sean

12
NGUI 3 Support / Re: Sudden UIPanel Problems (clipping and dragable)
« on: January 12, 2013, 09:06:31 PM »
Updated Info:

So after more experimenting, I figured out the clipping issue. To handle UI scale I scale the UIAnchors above the panels. I was only scaling in X and Y, leaving Z as 1f, because zscale made no sense to me, but apparently doing that breaks the clipping. I think I read something about non-uniform scale breaking clipping in another post, so I have no idea how that's worked up until recently, but clearly my bad.

However, the UIDraggable scale not working is still an issue. I find that if I restrict it to X axis only (1,0,0) it actually works and only moves in X, but if I restrict it to Y only (0,1,0), it still moves in X.

13
NGUI 3 Support / Sudden UIPanel Problems (clipping and dragable)
« on: January 12, 2013, 08:43:07 PM »
So I've been using NGUI for a while and all of the sudden some of my UI that was previously working stopped. It's not a part I test very often, so I'm not sure what change caused it (an NGUI update, or a Unity update, or something else), but I do know I haven't actually touched the UIObjects since they were working. So, what's happening is two-fold. One, the UIDraggable Panel script is ignoring the Scale attribute. It is set to 0, 1, 0, but is allowing dragging in all directions. The other issue is that clipping has stopped working. Instead of soft-clipping, its now just hiding all the panel contents all the time. I checked the gizmos, and they are all in the right place. In the editor, it doesn't work right either, except in the camera preview for the relevant uipanel.

So, anyway, I'm lost. The setup is as follows:

UIRoot->UIAnchor->ParentPanel(NoClipping)->(UIDraggablePanel with soft clipping)->child labels to be clipped
and then, as a sibling of the UIDraggablePanel, is a sliced sprite with UIDrag Panel Contents and a box collider.

I thought it might be the parent panel, so tried removing it, and that made it look correct in the editor, but it still fails completely when I play. My general camera/ui setup is a separate UIRoot and UICamera for each UI "layer" (so, I have one inventory root and camera, one game overlay root and camera, ect). Like I said initially, all this worked perfectly a month or two ago, but when I came back to it after not having tested/used it in a while, it was all broken. Any ideas?

-Sean

14
NGUI 3 Support / Re: NGUITools.cs line 467 Bug?
« on: August 28, 2012, 07:37:11 PM »
One more update. My suggested fix above is what actually causes the other error (the hidden tenderer errors) so I guess its a trickier problem. I'm now stumped, so hopefully you guys have an idea. I can delay the event until the next non-physics frame if I have to, but that's going to be a bit clunky, so I'd rather not if its not necessary.

15
NGUI 3 Support / Re: NGUITools.cs line 449 Bug?
« on: August 28, 2012, 07:13:29 PM »
Looks like in the newest ngui the line is now 467. updating top comment.

Pages: [1] 2