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.


Topics - sintua

Pages: [1] 2
1
I updated from a pretty old version of nGUI and I'm still finding a few strange quirks, one of which is UIButton no longer detects middle/right clicks? It looks like it has code to explicitly ignore this... Why was this changed?

I assume the suggested course of action is to use an eventTrigger's OnClick since that doesn't have such a limitation, but I'm not clear on why UIButton blocks it but eventTrigger doesn't; I don't want to switch all of these to use eventTrigger's just for that one to be changed as well in some later version to match?

2
Heya! I recently discovered Unity's wonderful LineRenderer, but obviously this doesn't always play nice with nGUI.
I was wondering what everyone else/ArenMook use for drawing lines in nGUI?

I was previously using a very hacky collection of "I" and "L" sliced sprites and flipping them around, using some complex handlers to join their ends together... it mostly worked but it was painful and prone to breaking.

As the LineRenderers aren't part of nGUI, the main problems I'm finding are depth related and not being clipped by panels. I might be able to finagle/fake the depth management but no clue where to start with the clipping if it's even possible.

thank you for your time!

3
NGUI 3 Support / Difficulty converting 2D UI to 3D
« on: July 01, 2017, 11:23:49 AM »
Heya! I'm returning to work on a game I hadn't touched in years (I think it was ngui 3.3.x or such?), and after updating Unity and my Libraries and getting everything sorted, I'm trying to convert my ui to 3D. It mostly seems in place except for a strange behaviour where when I start my game, it generates a TON of additional UIRoots with Cameras, and renders the scene in Ortho again.
The main camera that existed before running has it's culling changed from Everything to mixed (all but UI) so it doesnt render the 3D ui, and if I delete all the new UIRoots the ortho gui disappears, and resetting the main camera's culling back to everything renders it correctly in 3d.
I can interact with basic elements (scrolling, hovering, clicking things that just play tweens), but when I try to open a new menu it spawns a whole new batch of UIRoots and does the same culling change, ortho view, etc.
The code that seems to trigger it is NGUITools.AddChild:
  1. CorporationMenu menu = NGUITools.AddChild(this.CenterView, this.CorporationMenu.gameObject).GetComponent<CorporationMenu>();

Does this sound like something you recognize? Let me know if you need additional information.


4
NGUI 3 Support / Advice for adding OpenOn.Hover to UIPopUpList?
« on: January 27, 2015, 03:13:37 PM »
I've got the start of it easily enough, adding to the enum and:
  1. void OnHover(bool isOver)
  2.         {
  3.                 if (openOn == OpenOn.Hover && isOver)
  4.                         Show();
  5.                 else if (openOn == OpenOn.Hover && !isOver)
  6.                         Close();
  7.         }
But the problem is once you try to go over the options it closes... so how would I make it detect being over the popup options as well, and only closing if the mouse is off both the original button and the dropdown's background? I imagine it involves adding a collider to the background sprite and some other reference to see if it's hovered over as well, but I'm not sure how that'd work since I don't think it'd call the UIPopUp.cs OnHover method?

5
NGUI 3 Support / How to work around [00] alpha encoding in labels?
« on: January 26, 2015, 05:12:18 PM »
I use encoding to change colours of the text in a string, but I also need to include [10] and etc in the label, which turns the thing transparent. I can't even escape the encoding with a [[10], and I can't disable encoding because I use it for colour.
Is there an escape character so prevent the label from taking any [##] string and changing it to an alpha? the [any6characters] limitation was mildly obnoxious, but not being able to put 2 characters in brackets is causing problems all throughout my game, not even just this label.

Is there not an escape character for when we actually just want to type a bracket without invoking the encoding?


6
NGUI 3 Support / Only one tweenPosition plays at a time
« on: February 14, 2014, 05:30:22 PM »
And I've run into yet another problem trying to implement tweens.
I've got a "ticker" on the bottom, with headlines form left to right. what's supposed to happen is it adds a new item off screen to the left, then tweens all the headlines to the right based on the new items width (putting the new item in the bottom left corner).

This only works for the FIRST item, though, as every other item just jumps to the new position.

On a related note, is there a way to force the anchor resizing? the headline background/button is supposed to be the width of the label which works, but when I'm adding the item and tweening everything, the headline background width hasn't resized according to its anchors yet, so the width is wrong (uses the default prefab size). I got it to work by looking at the label's width and manually adding the sum of spacing around it, but that's not ideal.
(int width = 40 + 6 + uipLine.Label.width + 10;//icon+spacing+label+spacing)
  1. void AddActiveHeadline(Headline headline)
  2.         {
  3.                 Debug.Log("Adding Headline:" + headline.Title);
  4.                 //create GUI element
  5.                 UIPHeadlineButton uipLine = UIPHeadlineButton.Create(this.TickerBar, headline);
  6.                 //get width for positioning, tweens
  7.                 int width = uipLine.Background.width;//TODO returns INCORRECT WIDTH, not yet resized according to anchors
  8.                 //move new headline to bottomleft, off screen by width
  9.                 Vector3 offPos = uipLine.transform.localPosition;
  10.                 offPos.x -= width;
  11.                 uipLine.transform.localPosition = offPos;//move offscreen by width
  12.                 //add to active headlines
  13.                 this.ActiveHeadlines.Add(uipLine);             
  14.                 //slide headlines
  15.                 Debug.Log("Tweening Headlines");
  16.                 foreach (UIPHeadlineButton hdln in ActiveHeadlines)
  17.                 {
  18.                         hdln.TweenPos.SetStartToCurrentValue();
  19.                         //get "to" pos
  20.                         Vector3 pos = hdln.transform.localPosition;
  21.                         pos.x += width;
  22.                         hdln.TweenPos.to = pos;
  23.                         //play
  24.                         hdln.TweenPos.PlayForward();
  25.                 }
  26.         }
  27.  

EDIT: I've tried this with a for loop instead in case that was the problem, but same issue: only the first tween executes, and the other items just "jump" to the "to" position.
I also noticed a strange thing... If I click on the object in the inspector and activate the tween component, it stays active for as long as the tween *would* take to play, then jump to the end position and turns off. so it's acting like it's playing, but it's not actually animating out the tween.

  1. for (int i = ActiveHeadlines.Count-1; i>=0; i--)
  2.                 {
  3.                         UIPHeadlineButton hdln = ActiveHeadlines [i];
  4.                         hdln.TweenPos.SetStartToCurrentValue();
  5.                         //get "to" pos
  6.                         Vector3 pos = hdln.transform.localPosition;
  7.                         pos.x += width;
  8.                         hdln.TweenPos.to = pos;
  9.                         //play
  10.                         hdln.TweenPos.PlayForward();
  11.                 }
  12.  

7
NGUI 3 Support / TweenPosition misaligning sprites at random?
« on: February 07, 2014, 04:38:55 PM »
Tweens in NGUI seem to always give me the most hassle... the latest problem:
I'm using TweenPosition.Begin(target, duration, to) to move a menu onto the screen; in the picture below, the Agency menu slides in from the right. The problem is it comes in looking like it does in tween2.png with misaligned sprites! if I refresh that window, alt+Tab out and into Unity, mouse over the buttons (adjusts the sprite UIButton's tweencolor.hover is pointing at) or basically do anything to make the logic update, it corrects the contents. Ideally, it looks right the entire time.

It's doing this for all the menus, though the sprites that are incorrectly shifted seems to always be the same (tween2 is always how agencymenu looks when tweened in), even though there's no difference in the actual prefabs used to make those buttons. It looks like they have the right transforms in Inspector, but they just don't show it 'till refreshed.

8
Heyo! So I have a UIPLabel which is simply a label with a button behind it that expands to fit the label as it gets longer, and a title on top.


However, The actual dimensions of the base widget (shown in the picture below) *were* hardcoded to the size of the titlebox. The problem with this is when the widget's dimensions go off the scrollview, the REST of the widget (the expanding labelButton) is culled!


I tried setting the base widget's dimensions to anchor to the Buttons, ensuring it wont be prematurely culled when scrolling... except this makes the whole label box float up into the scrollview, wavering left and right seemingly at random.


If I remove the anchors from the base widget it stops floating away, but then the old problem of the label being prematurely culled is back.


Is this a bug with anchoring to a resizing label? Or something else?

9
NGUI 3 Support / User-Selected Font?
« on: February 04, 2014, 02:10:04 PM »
Hi, I was wondering what the best way to implement a custom font selection on the user side with NGUI would be. This would entail changing the font selection in every label already in the scene, as well as the fonts on the prefabs (or at least, change them as soon as they're instantiated).

I don't know if this is something where I should be putting a script on everything with a label and have it check or subscribe to some FontSelectionChanged event, or have one script that finds all the labels and changes them (in the prefabs as well, or modify the prefab create methods to load the current font of choice).

Has anyone built something similar?

(Side note: It's hard to find useful posts about fonts, because most search terms just pull up the tons of dynamic and bitmap font problem threads, so sorry if this was asked before and I didn't see the thread)

10
NGUI 3 Support / Code design: updating the widgets in a scroll view
« on: January 22, 2014, 12:54:51 PM »
I figure someone on here's tried the same thing and hit the same problem, though this isn't a problem with NGUI specifically but rather a design issue that i think a lot of NGUI users have faced.

I have a scrollview that shows a list of widgets based on the contents of a list (i.e. a list of buttons for each character, or an inventory, etc. drawing from list<Character> or list<InventoryItem>). What's the best way to keep the list up to date with changes?

Ideally, I can give the UIPList.cs script a list<>, have it figure out the contents, make buttons, and post them. This all works so far, but if something is added or removed from the list, it won't update. I considered checking the list.count and updating if it changed, but worried the list might remove and add something in one process, missing the check and not updating. I've also tried adding a DestroyedEvent to an object which works for tracking when to remove things, but is a bit clunky to add to everything and doesn't catch for adding things (which would require another event in the create method, further clunkiness).

Has anyone made something to this effect? any clever solutions?

11
Say I want to make a bar that runs along the top of the screen. I anchor the left and right sides to UIRoot, and it stretches across. Now, if I anchor the top to UIRoot, it disables the vertical dimension input, effectively locking the widget at whatever height it had before setting the top anchor.

This can be worked with by setting the bottom anchor to the target's top, then setting the desired height + any offset on the Top Anchor, but I'm guessing this isnt "as intended"?

I expected the dimension input to stay available with 0 or 1 anchors, disabled if I set anchors for both top/bottom. (the same issue for left/right)

12
NGUI 3 Support / Getting "pixel perfect" with perspective cameras?
« on: January 08, 2014, 09:07:55 PM »
Hi! I'm trying to create an effect that involves mixing the orthographic with perspective camera (visually).

The current menu is "flat" on the screen, pixel perfect and clearly legible as you get with an orthographic camera. If selecting the OtherMenu button, that button stays "flat" and the rest of the OtherMenu contents slide out from that position, while FirstMenu "falls" into the background at a skewed angle.

Imagine it like the main GUI is a piece of paper taped to your screen, then it's cut out and 'falls' behind the screen in 3D space.

What would be the best - if at all - possible way to get this effect? I've tried using just a perspective camera with the UI set flat and it mostly works, except it isn't pixel perfect so text and pixel art sticks out like a sore thumb.

EDIT: I realize it won't be pixel perfect after it moves into perspective, but that's fine. I only need the front menu to be crisp and legible.

13
NGUI 3 Support / Figuring out the *actual pixel width* of a label?
« on: July 06, 2013, 04:04:16 PM »
Is this information anywhere? Usually you can look at scale.x for sprites, but not for labels/text.
I'm trying to make a Sim City-esque ticker, but since the Headliens are all different lengths I can't figure out how to put them end to end. Shrinking the text to fit a prefit box makes them basically illegible, and the font isn't monospaced so calculating the # of characters*average character pixel width isn't very accurate.

I'm assuming the information is in there SOMEwhere since Shrink To Fit knows how wide the thing is.

14
NGUI 3 Support / Finding the length(x) of a label?
« on: March 17, 2013, 02:55:28 PM »
I don't know if anyone has come across this issue, but: I would like to find the length of a label. Given that label's "scale" is used for something other than the actual width, is there a way to pull this off? I'm sure I could do some math on the length of the string but that wouldn't account for the non-monospace font.

Specifically, I'm trying to create a "ticker" sort of effect like SimCity with various-length headlines scrolling along the bottom, with windows sized to hold the headline, starting just after the previous one finished and continuing in a scroll. I'll need the label length to size the text window, and to connect them in one continual string.

15
NGUI 3 Support / TweenPosition only fires from OLD position!
« on: March 13, 2013, 10:46:25 PM »
basic concept:
tween a panel BY (300,0,0). (as in, move from its CURRENT position 300 to the right).
later, tween same panel (0,50,0). As in, move from its CURRENT position 50 up).

I wrote this, and it SHOULD work, but instead of moving it from it's current position, it ONLY moves the panel from it's ORIGINAL position. So the first tween slides it right like expected, but the next one SNAPS it back to 0,0,0 and tweens it up.

   
  1. static void Shift (GameObject menu, float duration, Vector3 shift)
  2.         {
  3.                 Vector3 pos = menu.transform.position;//starting position
  4.                 Debug.Log(string.Format("current x:{0},y:{1},z:{2}",pos.x, pos.y, pos.z));
  5.                 Debug.Log(string.Format("Shift x:{0},y:{1},z:{2}",shift.x, shift.y, shift.z));         
  6.                
  7.                 Vector3 newPos = new Vector3(pos.x+shift.x, pos.y+shift.y,pos.z+shift.z);
  8.                
  9.                 TweenPosition tween = TweenPosition.Begin(menu,duration,newPos);
  10.                 //tween.from = pos;
  11.         }

"pos" always returns something like "current x:-0.0001144976,y:0.1177472,z:0" so I'm not sure why menu.transform.position will SHOW the right coordinates in the inspector, but the actual data as revealed by the debug log is wrong. It seems that tweenposition doesnt *actually* move the thing?

EDIT

So I ended up making Shift do this, which seems really backward and obtuse, but if I dont then it won't actually tween from the current position! There has to be a better way. Note that this also only works from a 0,0,0. And since transform doesnt seem to get the actual location, I can't GET the panels location to tween from.

  1. static void Shift (GameObject menu, float duration, Vector3 shift)
  2.         {
  3.                 Vector3 pos;
  4.                 try
  5.                 {
  6.                         pos = menu.GetComponent<TweenPosition>().to;
  7.                 }
  8.                 catch (Exception ex)
  9.                 {
  10.                         pos= Vector3.zero;                     
  11.                 }
  12.                
  13.                 Debug.Log(string.Format("current x:{0},y:{1},z:{2}",pos.x, pos.y, pos.z));
  14.                 Debug.Log(string.Format("Shift x:{0},y:{1},z:{2}",shift.x, shift.y, shift.z));         
  15.                
  16.                 Vector3 newPos = new Vector3(pos.x+shift.x, pos.y+shift.y,pos.z+shift.z);
  17.                
  18.                 TweenPosition tween = TweenPosition.Begin(menu,duration,newPos);
  19.                 tween.from = pos;
  20.         }
  21.  

(also, a secondary question)
Is there any example of a tween's onFinished being used? For the life of me I can't get the thing to disable the object when a tween finishes.

Pages: [1] 2