Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static Tip[] tips;
- public class Tip : MonoBehaviour
- {
- public void Start()
- {
- if (tips == null)
- {
- tips = (Tip[]) FindObjectsOfType(typeof(Tip));
- System.Array.Sort(tips, new TipComparer());
- }
- Debug.Log("Tips sorted in this order:");
- foreach (Tip tip in tips)
- {
- DebugX.Log(" - "+tip.name);
- }
- }
- }
- public class TipComparer : IComparer<Tip>
- {
- public int Compare (Tip a, Tip b)
- {
- if (a.transform.position.x > b.transform.position.x) {
- return 1;
- } else {
- return -1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment