Author Topic: UIAnchor broken behaviour  (Read 2525 times)

MaRTiDoRe

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
UIAnchor broken behaviour
« on: November 05, 2013, 07:53:42 AM »
Hi Folks!

I'm having some problems with UIanchor behaviour.

I'm using version 2.7 (tried 3.x but it was a big fail because of backwards compatibility)

This is my scenario:

UI Root (2D)
    Camera
        Anchor
            MyGeneralPanel (UI panel)
                  MyClipingPanel (UI Panel with Hard clip activated)
                        ScrolleableObjectsParen (Empty gameobject, has nothing but a Transform)
                                  ScrolleableLabel(clone) (UILabels with some fancy scripts to add functionality)
                                  ScrolleableLabel(clone)
                                  etc.


So I have a general panel with buttons and stuff, and inside that panel I have a Cliping Panel (used for scrolling).

Inside that Cliping Panel I have an empty gameobject named ScrolleableObjects, where I add  labels dynamically.

Every time I add a new label, I check if it's the first one or not. If it's the first one, I attach the label to the ClipPanel.

Until here everything goes fine...

When I add a Label, and it's not the first one, I attach the new UILabel to the last Label (in fact, it works like a linked list where I always keep a reference to the last and the first label). The new label should position under the last label, but something weird happens.

Whenever I move the Y or X offset in the anchor script, the label moves unity by unit (from 0 to 1, and it ignores all the movement from 0.1 to 0.9), so the movement is very brusque.

Here a small picture:

-Purple square = ClipPanel
-Blue squares = UILabels
-Yellow lines = UIAnchor attachments



The first Label is attached to the ClipPanel, and its movement when I touch X and Y offset in UIAnchor works fine and smooth.

The second Label is attached to the first Label (through UIWidged field in UIAnchor), but the movement is broken.

Since I do all this things through code at runtime, I though that my problem might be in the code, but I recreated the same scenario by hand in the scene, and the problem still persists...

Anyone with this problem? Is this a known bug in versions 2.7 or earlier? Any solution?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIAnchor broken behaviour
« Reply #1 on: November 05, 2013, 01:08:22 PM »
Don't do this. Anchors are not particularly fast, and what you're trying to do should be done either by using a UIGrid for placement, or (less performant) -- a UITable.