Author Topic: Bizzarre UISprite/Label behavior. Content outside frames till refresh  (Read 6711 times)

coolaneasy

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 34
    • View Profile
Hi guys
So I have a UIGrid that has contents.
UIGrid
         -- 0
         -- 1

The content structure looks like this
UIWigdet
             ---UITexture
             ---GameObject
                                   ---UIPanel
                                                  ---Children
             ---UIPanel(***This UIPanel seems to create all kinds of problems)
                            ---UILabel
                            ---UISprite   

The clipping on the problematic UIPanel is set to None. I have it there only cause of depth reasons. I need the UILabel and UISprite to be on top of the first UIPanel.

Now the problem is when I add a second entry to the UIGrid, the UILabel and UISprite on the second entry are completely off. Note that their location is correct, meaning if you were to select the UILabel or UISprite in Unity editor, the bounds as indicated by Ngui's blue dots seem to be in the correct place. However their content is off of this outlined bounds. The moment there is any sort of refresh, by resizing the Game window, Grid's execute or UIScrollView's Reset clipping plane, the contents shift to their proper position.

Any thoughts if this is a bug? Whats going on?

Thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Bizzarre UISprite/Label behavior. Content outside frames till refresh
« Reply #1 on: October 17, 2014, 05:01:52 AM »
Are you doing any kind of scaling animations? Scaling from zero perhaps? Zero is invalid scale, so it does weird things with UI elements.

coolaneasy

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 34
    • View Profile
Re: Bizzarre UISprite/Label behavior. Content outside frames till refresh
« Reply #2 on: October 17, 2014, 12:56:02 PM »
No there is no animation going on and also I had checked all the way up to the parent for scale 0.
I fixed it though. Not exactly sure what was going on but before(and I'm using NData) when a second item of the type was added, I was clearing out the list and then creating a fresh list with that item's count set to +1. Now instead of clearing out the list, I simply set the NData's binding to +1 and the positioning got fixed. I feel like there might exist some situation where the draw call happens before the anchoring takes place and that puts the content off bounds. Must be quite rare though.

coolaneasy

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 34
    • View Profile
Re: Bizzarre UISprite/Label behavior. Content outside frames till refresh
« Reply #3 on: October 17, 2014, 12:57:45 PM »
oh Aren btw on an off topic note, theres a function called GetExactCharacterIndex in NGUIText.cs that returns a default 0. This means that it reports a valid index in situations where it couldn't find a url when you GetUrlFromPosition(lastmouseindex). This should probably be -1? At least seems to have fixed it for me.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Bizzarre UISprite/Label behavior. Content outside frames till refresh
« Reply #4 on: October 18, 2014, 08:51:20 AM »
That function isn't looking for URLs. It's looking for characters, and returns the closest character -- if nothing else, it will be the first one. -1 would be invalid.