duck

duck

Aug 10th, 2010
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.59 KB | None | 0 0
  1.  
  2.  
  3. static Tip[] tips;
  4.  
  5. public class Tip : MonoBehaviour
  6. {
  7.     public void Start()
  8.     {
  9.         if (tips == null)
  10.         {
  11.             tips = (Tip[]) FindObjectsOfType(typeof(Tip));
  12.             System.Array.Sort(tips, new TipNodeComparer());
  13.         }
  14.        
  15.         Debug.Log("Tips sorted in this order:");
  16.         foreach (Tip tip in tips)
  17.         {
  18.             DebugX.Log("  - "+tip.name);
  19.         }
  20.    
  21.     }
  22. }
  23.  
  24.  
  25.  
  26. public class TipNodeComparer : IComparer<Tip>
  27. {
  28.     public int Compare (Tip a, Tip b)
  29.     {
  30.         if (a.transform.position.x > a.transform.position.x) {
  31.             return 1;
  32.         } else {
  33.             return -1;
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment