Author Topic: Long Popup List  (Read 23777 times)

Russel

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: Long Popup List
« Reply #30 on: June 13, 2013, 12:29:56 PM »
Could this be a rounding error? Or is this a completely wrong approach?
I need quick help. Thank you!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Long Popup List
« Reply #31 on: June 13, 2013, 05:22:18 PM »
That's because you are dividing an integer by another integer. You need to work with floats, not integers.

Russel

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: Long Popup List
« Reply #32 on: June 14, 2013, 02:26:30 AM »
Thank you! Yes, that was the problem. You saved my day  ;).

huhudage

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Long Popup List
« Reply #33 on: July 04, 2013, 07:10:30 AM »
I fixed the problem about Highlight's position, just change mHightlight's parent from Dropdown-list to the the Panel.

sonicviz

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 58
    • View Profile
Re: Long Popup List
« Reply #34 on: July 19, 2013, 05:34:21 AM »
Hi,
Thanks for the work on this.

I'm trying it out but I'm getting clipping issues with the drop down text at the bottom, as shown in the attached image.

Any clues on how to make it clip within the border properly?

ty!

sonicviz

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 58
    • View Profile
Re: Long Popup List
« Reply #35 on: July 19, 2013, 07:20:32 AM »
I don't know why but I had to adjust the scrollbar and clipping by  - 10

  1.             //. scrollbar Background
  2.             mScrollBar.background = NGUITools.AddSprite(mScrollBar.gameObject, atlas, scrollBackgroundSprite);
  3.             mScrollBar.background.depth = NGUITools.CalculateNextDepth(mChild);
  4.             mScrollBar.background.gameObject.name = "Background";
  5.             mScrollBar.background.cachedTransform.localScale = new Vector3(10, popupHeight -10, 1);
  6.             BoxCollider bc1 = NGUITools.AddWidgetCollider(mScrollBar.background.gameObject);
  7.             bc1.center = new Vector3(bc1.center.x, -0.5f, bc1.center.z);
  8.  
  9.             //. scrollbar Foreground
  10.             mScrollBar.foreground = NGUITools.AddSprite(mScrollBar.gameObject, atlas, scrollForegroundSprite);
  11.             mScrollBar.foreground.depth = NGUITools.CalculateNextDepth(mChild);
  12.             mScrollBar.foreground.gameObject.name = "Foreground";
  13.             mScrollBar.foreground.cachedTransform.localScale = new Vector3(10, popupHeight -10, 1);
  14.             BoxCollider bc2 = NGUITools.AddWidgetCollider(mScrollBar.foreground.gameObject);
  15.             bc2.center = new Vector3(bc2.center.x, -0.5f, bc2.center.z);
  16.  
  17.             //. assign scrollbar to panel
  18.             mChildDraggablePanel.verticalScrollBar = mScrollBar;
  19.  
  20.             // setting panel's clip area
  21.             mChildPanel.clipping = UIDrawCall.Clipping.HardClip;
  22.             float clipW = x;
  23.             float clipH = popupHeight -10;// -y + bgPadding.y;
  24.             mChildPanel.clipRange = new Vector4(clipW / 2, -clipH / 2, clipW, clipH);

KovaaK

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: Long Popup List
« Reply #36 on: May 03, 2014, 12:08:37 PM »
Just as a heads-up to anyone else who arrives here via google search, the code attached in previous posts seems to have been written before some changes to how NGUI handles depth.  I'm far from an expert in this environment (only first heard of NGUI a week ago and dug into it a few days ago), but I fixed some issues related to the dropdown text not being drawn by going near line 500 in UIPopupListEx.cs (where these lines are):
  1.             //. Draggable Panel
  2.             mChildPanel = NGUITools.AddChild<UIPanel>(mChild);
  3.             mChildDraggablePanel = mChildPanel.gameObject.AddComponent<UIDraggablePanel>();
  4.             mChildDraggablePanel.scale = new Vector3(0, 1, 0);
  5.             mChildDraggablePanel.scrollWheelFactor = 1;
  6.             mChildDraggablePanel.showScrollBars = UIDraggablePanel.ShowCondition.Always;
  7.  
and changing it to:
  1.             //. Draggable Panel
  2.             mChildPanel = NGUITools.AddChild<UIPanel>(mChild);
  3.             mChildPanel.sortByDepth = true; // Depth issue fix - KovaaK
  4.             mChildDraggablePanel = mChildPanel.gameObject.AddComponent<UIDraggablePanel>();
  5.             mChildDraggablePanel.scale = new Vector3(0, 1, 0);
  6.             mChildDraggablePanel.scrollWheelFactor = 1;
  7.             mChildDraggablePanel.showScrollBars = UIDraggablePanel.ShowCondition.Always;
  8.  

And I apologize for the really old thread bump.

Lumos

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 4
  • Posts: 21
    • View Profile
Re: Long Popup List
« Reply #37 on: June 05, 2014, 12:10:17 PM »
Excuse my slight thread necromancery, but I found the posted scrollable list completely useless, as it failed to work for me - let's face it, it's from 2012 and quite a bit of things have changed in NGUI 'till now; even porting the bloody thing was a pain in the arse. This led me to create a replacement, which I hope will prove more useful to everyone.

</shameless self-advertising>