duck

duck

Jun 25th, 2010
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. -- SequenceItem.js --
  3.  
  4. private static var numItems = 20;
  5. private static var items : Transform[];
  6.  
  7. public var index = -1;  // (value when not set)
  8.  
  9. function Start() {
  10.     if (items == null)
  11.     {
  12.         // probably needs error checking: will fail if objects not named/don't exist/don't have script attached!
  13.         items = Transform[numItems];
  14.         for (var n = 1; n <= numItems; ++n) {
  15.             items[n] = GameObject.Find("item "+n).transform;
  16.             var sequenceItem : SequenceItem = items[n].GetComponent("SequenceItem");
  17.             sequenceItem.index = n;
  18.         }
  19.     }
  20. }
  21.  
  22. function OnMouseDown() {
  23.     // need error checking here
  24.     var nextItem = items[index+1];
  25.     var prevItem = items[index-1];
  26. }
Advertisement
Add Comment
Please, Sign In to add comment