duck

duck

Jun 18th, 2010
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. static var clickMaster : Clickable
  3.  
  4. function ClickMaster() : Clickable
  5. {
  6.     if (clickMaster == null)
  7.     {
  8.         clickMaster = this;
  9.     }
  10.     return clickMaster;
  11. }
  12.  
  13. function PixelClick(type : String)
  14. {
  15.     do the raycast,
  16.     check if a 'clickable' compnent is attached to the collider's GO
  17.     if so, sendmessage "type" to the clickable's root gameobject
  18. }
  19.  
  20. function Update() {
  21.     if (ClickMaster() == this)
  22.     {
  23.         // I am the master of clicks!
  24.        
  25.         if (Input.GetMouseButtonDown(0)) { PixelClick("LeftMouseDown"); }
  26.         if (Input.GetMouseButtonUp(0)) { PixelClick("LeftMouseUp"); }
  27.         if (Input.GetMouseButtonDown(1)) { PixelClick("RightMouseDown"); }
  28.         if (Input.GetMouseButtonUp(1)) { PixelClick("RightMouseDown"); }
  29.    
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment