Author Topic: Suggestion of the custom sort implementation of UIGrid.  (Read 2835 times)

ppc

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Suggestion of the custom sort implementation of UIGrid.
« on: March 28, 2014, 01:51:25 AM »
I want a custom sort to make early because I want to use the name of the gameObject in the purpose except the sort.

UIGrid.cs
  1.         // you can set Cusntom Comparer
  2.         public System.Comparison<Transform> CustomComparer { get; set; }
  3.  
  4.         public virtual void Reposition()
  5.         {
  6.                 ....
  7.  
  8.                 if (sorting != Sorting.None || sorted)
  9.                 {
  10.                         List<Transform> list = new List<Transform>();
  11.  
  12.                         for (int i = 0; i < myTrans.childCount; ++i)
  13.                         {
  14.                                 Transform t = myTrans.GetChild(i);
  15.                                 if (t && (!hideInactive || NGUITools.GetActive(t.gameObject))) list.Add(t);
  16.                         }
  17.  
  18.                         if (sorting == Sorting.Alphabetic) list.Sort(SortByName);
  19.                         else if (sorting == Sorting.Horizontal) list.Sort(SortHorizontal);
  20.                         else if (sorting == Sorting.Vertical) list.Sort(SortVertical);
  21.                         else if (sorting == Sorting.Custom && CustomComparer != null) list.Sort(CustomComparer); // CustomSort
  22.                         else Sort(list);
  23.  
  24.                         ....
  25.                 }
  26.                 ....
  27.         }
  28.