Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Can I rotate GUITexture?

Discussion in 'Scripting' started by mongkon, Jan 31, 2006.

  1. mongkon

    mongkon

    Joined:
    Oct 30, 2005
    Posts:
    3
    Can I rotate GUITexture?
    I try to rotate GUITextuer x,y,z but not work??
     
  2. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
    The GUI Texture is built on a plane right in front of your camera and can't be rotated (I'm pretty sure). Try making 2 cams, your game cam following the action and one stationary pointed at your "3D" GUI setup... they will overlap in Game view properly with some tweaking. This multi camera rendering setup in Unity is pretty versatile.
     
  3. Mr. Animator

    Mr. Animator

    Joined:
    Oct 2, 2005
    Posts:
    193
    So you can have two different cameras layer what they are seeing into one game view? That would be a really cool way to make UI's... how would you go about setting that up exactly? It would also be great (actually, rather necessary) for a first person shooter to have a gun visible in the camera view that doesn't clip into objects and walls when you get too close.
     
  4. NCarter

    NCarter

    Joined:
    Sep 3, 2005
    Posts:
    686
    It's pretty simple to set up:

    • Reserve a layer for your GUI.
    • Make a new camera for the GUI, and set its culling mask to only view the GUI layer. Set its clear flags to be either Don't Clear or Depth Only, depending on what you're doing. Set the Depth to be anything greater than your other cameras are using.
    • Make sure your normal camera(s) can't see the GUI layer.
    • Put all your GUI objects (which can be absolutely anything, not just GUITexts etc.) into the GUI layer.
    That's it, really. Since you can draw any kind of object when doing GUIs in this way, you're free to rotate text and bitmaps, or even to draw full 3D objects.

    Incidentally, I suggest building the GUI objects at the world origin so that it's easier to work out where to put them when setting their positions from scripts.

    If you were trying to do a FPS character's gun, you'd do a very similar kind of thing with separate cameras and layers to make sure the gun is drawn after everything else and in a way that ignores all depth information from previously drawn objects.

    As a further example, in my Unity version of my game Rescue, I have three cameras: one to draw the stars and distant nebulae, one to draw everything else outside of the cockpit, and another to draw the cockpit interior (which is also full 3D). You can do some pretty flexible things with this. :)
     
  5. Mr. Animator

    Mr. Animator

    Joined:
    Oct 2, 2005
    Posts:
    193
    Thanks for the detailed reply, this is a really powerful tool! Perhaps the unity manual should feature a how-to on this, as it is a technique usable by pretty much any game.
     
  6. mongkon

    mongkon

    Joined:
    Oct 30, 2005
    Posts:
    3
    Thank you. :D