GUICam

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
m (Reverted edits by Joseph05408 (Talk); changed back to last version by DGuy)
m (added Boo category)
Line 1: Line 1:
 +
[[Category: Boo]]
 
Here is the script I attach to a camera that holds a Rect with the cameras pixels in GUI co-ordinate space.  
 
Here is the script I attach to a camera that holds a Rect with the cameras pixels in GUI co-ordinate space.  
  

Revision as of 06:44, 21 July 2010

Here is the script I attach to a camera that holds a Rect with the cameras pixels in GUI co-ordinate space.

import UnityEngine 

class GUICam (MonoBehaviour): 

  public GUIRect as Rect 
  cam as Camera 
   
  def Start(): 
     cam = transform.camera 

  def Update (): 
     pr=cam.pixelRect 
     r = cam.rect 
     screenHeight = pr.height / r.height 
     GUIRect = Rect(pr.left,screenHeight-(pr.top+pr.height),pr.width,pr.height) 
      


to use I put this on GUI generation script which is a camera component and draw a button in the top left of the camera viewport.

  aGUICam as GUICam 

  def Start (): 
     aGUICam = transform.camera.GetComponent(GUICam) 

  def ButtonGUI(): 
     r=aGUICam.GUIRect 
     GUI.Button ( Rect (r.xMin+10,r.yMin+50,50, 30), "button"))
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox