Author Topic: TweenPosition misaligning sprites at random?  (Read 3918 times)

sintua

  • Jr. Member
  • **
  • Thank You
  • -Given: 7
  • -Receive: 0
  • Posts: 63
    • View Profile
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.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TweenPosition misaligning sprites at random?
« Reply #1 on: February 08, 2014, 02:48:43 PM »
Are you using scroll views in there?

sintua

  • Jr. Member
  • **
  • Thank You
  • -Given: 7
  • -Receive: 0
  • Posts: 63
    • View Profile
Re: TweenPosition misaligning sprites at random?
« Reply #2 on: February 09, 2014, 09:28:56 PM »
Yeah, the two columns in the window are scroll views with buttons in them. Do tweens not work with scroll views? is there a way around this problem?
« Last Edit: February 10, 2014, 03:39:39 PM by sintua »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TweenPosition misaligning sprites at random?
« Reply #3 on: February 10, 2014, 04:45:50 PM »
To be honest I vaguely remember there being some catch to tweening scroll views from off-screen, but what it was... escapes me right now. Can you tween the scroll view's parent instead?

sintua

  • Jr. Member
  • **
  • Thank You
  • -Given: 7
  • -Receive: 0
  • Posts: 63
    • View Profile
Re: TweenPosition misaligning sprites at random?
« Reply #4 on: February 12, 2014, 07:56:32 PM »
Actually I am tweening the scrollview's parent. The base object is the menu's script and a panel which holds the window's gui bits, the top two buttons, and the two scrollviews (which in turn hold their own buttons). the tween is applied to the base menu/panel object.

It's frustratingly inconsistent with when it happens... perhaps it has something to do with the activation? the menus are stored deactivated, then when they're called, they activate (Menu.SetActive(true)), then the tween is set up, then its activated and slides onto the screen.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TweenPosition misaligning sprites at random?
« Reply #5 on: February 13, 2014, 12:28:25 AM »
I redesigned how content positioning works earlier tonight. You can now set the content origin on your scroll views, and your scroll position is respected even if you resize the scroll view. So... next update should also resolve the issue you've encountered. But if not, just let me know.

sintua

  • Jr. Member
  • **
  • Thank You
  • -Given: 7
  • -Receive: 0
  • Posts: 63
    • View Profile
Re: TweenPosition misaligning sprites at random?
« Reply #6 on: March 06, 2014, 11:21:57 PM »
Heya, so I'm using 3.5.0 and I don't see anything since that affects panels/tweens/etc, and I'm still having this problem. I can't tween anything with a scrollview child in there somewhere without the gui breaking down. forcing constant repositioning sometimes fixes *parts* of the visual glitch but not always, and this effectively disables the scrolling anyway.

As it stand I can't tween any of my menus without anything in a scrollview glitching out, with what gui elements show up doing so seemingly at random.
Frustratingly, alt tabbing out then back in seems to make the GUI draw properly.

This particular menu doesn't seem to have the misaligning problem the other ones do (this one slides down ~100 px, the first post example had them sliding in from the side), but has the "random elements disappear" issue.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TweenPosition misaligning sprites at random?
« Reply #7 on: March 07, 2014, 08:56:42 AM »
Current latest is 3.5.3, not 3.5.0 :P

sintua

  • Jr. Member
  • **
  • Thank You
  • -Given: 7
  • -Receive: 0
  • Posts: 63
    • View Profile
Re: TweenPosition misaligning sprites at random?
« Reply #8 on: March 07, 2014, 12:53:04 PM »
yeah, but as I said I didn't see anything between 5.0-5.3 that affected this sort of thing. I'll update anyway, then.

Updated: The only change is now alt-tabbing away and back no longer corrects the gui. As soon as I move the scroll bars it corrects, still... but it comes in broken as shown in the above post.
« Last Edit: March 07, 2014, 01:25:42 PM by sintua »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TweenPosition misaligning sprites at random?
« Reply #9 on: March 08, 2014, 12:13:54 PM »
What kind of tweens are you doing? Tweening anything from a scale of zero will break the UI as you can't divide by zero, and a scale of zero is invalid.