duck

duck

Jun 18th, 2010
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private var root : Clickable;
  2.  
  3. function Start() {
  4.  
  5.     if (root == this)
  6.     {
  7.         SpreadToChildren();
  8.     }
  9. }
  10.  
  11. function SetRoot(Clickable root)
  12. {
  13.     this.root = root;
  14. }
  15.  
  16. function SpreadToChildren()
  17. {
  18.     for (Collider c in GetComponentsInChildren(Collider))
  19.     {
  20.         if (c.GetComponent(Clickable) == null)
  21.         {
  22.             c.gameObject.AddComponent(Clickable);
  23.             c.SetRoot(this);
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment