Author Topic: Create Labels in script  (Read 32372 times)

astanton81

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Create Labels in script
« Reply #15 on: March 19, 2015, 09:17:07 PM »
I might be missing something, but why can't you sort the list prior to adding them into the game, so that when you are going through the for loop adding the items, they are already sorted?

harrisonpink

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 29
    • View Profile
Re: Create Labels in script
« Reply #16 on: March 20, 2015, 12:14:00 AM »
Well, I'm going to want to expand this list by allowing the user to sort by other criteria such as card cost, so id like to be able to sort the list live.

(also the solution was super simple. it's just adding the following line in the foreach loop:

  1. go.name = pickedCard.name;

I told you it had been a long time since I coded!)

harrisonpink

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 29
    • View Profile
Re: Create Labels in script
« Reply #17 on: March 20, 2015, 12:59:10 AM »
I've successfully got the library creating the list and alphabetizing it. I've encountered some new problems now.

If I add a UIScrollView to the parent object (temp_library) and a UIDragScrollView to the prefab that makes up the list items, I get the following error, after which nothing spawns:

"You can't place widgets on a layer different than the UIPanel that manages them.
If you want to move widgets to a different layer, parent them to a new panel instead."

I assumed this meant the depth of the objects, but that can't be the case because I have plenty of other objects all spawning on different layers, so I don't understand this error.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Create Labels in script
« Reply #18 on: March 21, 2015, 09:31:08 PM »
Game object layer must match. Widgets must be on the same layer as panels, as the error message tells you.

NGUI forces this behaviour.

harrisonpink

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 29
    • View Profile
Re: Create Labels in script
« Reply #19 on: March 24, 2015, 12:01:28 PM »
Thank you for the reply! Just to clarify, are you talking about Unity Layers? http://docs.unity3d.com/Manual/Layers.html

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Create Labels in script
« Reply #20 on: March 25, 2015, 12:06:36 PM »
Yup.