Author Topic: nGUI tween scale label problem  (Read 3063 times)

ekhnaton

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
nGUI tween scale label problem
« on: November 30, 2016, 06:27:24 AM »
Hi all,

I have a mobile application with a quite too complex nGUI-based UI, and there is a label with tween scale that makes interesting error. I've made a short video of the problem:
https://www.youtube.com/watch?v=eYySwT3njN8&feature=youtu.be

Also screenshot to check the hierarchy and inspector:





I really need some hints about what is happening, and how to fix this.

Thanks,
Paul


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: nGUI tween scale label problem
« Reply #1 on: November 30, 2016, 03:31:37 PM »
If you are going to tween something, make sure that it doesn't have an anchored child. In your case you do -- and it's updated every update at that. The two effectively conflict -- one changes the scale, the other tries to compensate. Weird things happen.

ekhnaton

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: nGUI tween scale label problem
« Reply #2 on: December 01, 2016, 02:55:15 PM »
Thanks for your answer.

Actually I don't think it is because of the anchoring. If I turn of the tween child label's anchors, it also doeas the same, except the label does not show at all. (it shows up -580px left)

Any other idea what causes this?

Thanks,

ekhnaton

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: nGUI tween scale label problem
« Reply #3 on: December 01, 2016, 03:48:47 PM »
Okay, you were right about the tween is confusing the table cell positions because of other table element's anchors.

I found a basic solution: I switched the table cell alignment from "top left" to "top".

This works smooth, but only if every table element's transform.X = 0. Otherwise 'weird things happen'.

Problem is, that every tween motion adds a number to all gameobject's transform.X, and after 3-4 tweens the whole table blows up. I could write a function that always set transform.X=0, but it seems a really clumsy way to solve this.

Another question: I'm not experienced in nGUI, I came to Unity from web dev, and in html is soooo much easier to make anything like this UI. Why is a responsive scrollview with some things in it so awfully hard to make? Is it too much for nGUI, or am I doing it in a very wrong way? (I worked weeks on this **** scrollview - still doesn't work properly, and in html it would take 20-30 minutes to make alltogether - I'm very frustrated :) )

Thanks, - and sorry for my lang, I'm not native english speaker

ekhnaton

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: nGUI tween scale label problem
« Reply #4 on: December 01, 2016, 04:14:31 PM »
Here is a very basic question: can I make a responsive UI in nGUI without anchoring all elements to UI Root or each other? (and if there is no other way, why this tween animation not compatible with them?)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: nGUI tween scale label problem
« Reply #5 on: December 02, 2016, 01:41:46 AM »
You don't need to anchor anything at all. Use a top-left pivot point for everything, and it will behave like the website you're expecting. At most all you will need to do to anchor something to top-left, is to put an anchor on the parent object -- that's it. Note that it's the only one object. If you anchor the parent, all children will automatically be anchored just because they're children of that object. You're probably way overthinking it / overcomplicating it by trying to use anchors everywhere for no good reason. A simple scroll view is trivial to make.

1. New scene.
2. ALT+SHIFT+S, stretch it to form your scroll view's background. ALT+SHIFT+C to give it a collider.
3. Right click it (make sure the rect mode is toggled [press T]), choose to add a scroll view. Stretch it to cover the panel.
4. Back on the sprite add a UIDragScrollView script to it, target the scroll view from step 3.
5. Add elements inside your scroll view by selecting the scroll view and using ALT+SHIFT+S or any other shortcut to add widgets.

if you want to anchor this to say, top left corner of the screen, clear your selection and hit ALT+SHIFT+W to make an invisible widget. Anchor it to top left, then reparent your sprite / scroll view to be its child.