Author Topic: [Solved] HUD Text + camera.rect issue  (Read 3902 times)

aprendaGames

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
[Solved] HUD Text + camera.rect issue
« on: March 31, 2013, 07:05:48 PM »
The game screen is split into 2 parts. The bottom half is all 2d UI, while the top is a 3d scene. To do this I am doing the following on the 3d camera:
  1. camera.rect = new Rect(0f,.39f,1f,.61f);

All works fine except that the HUD text shows up in a different spot than what I expected. In fact, it looks a lot like it's in the right spot if the 3d camera took up the whole screen.

Thanks!
« Last Edit: April 01, 2013, 03:22:29 PM by aprendaGames »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: HUD Text + camera.rect issue
« Reply #1 on: March 31, 2013, 10:12:27 PM »
The script you're looking for is UIFollowTarget. It converts the coordinates in its Update() function -- lines 87 and 98. Make sure it's using the correct cameras. If it is, then you likely need to make it use the rect there.

aprendaGames

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: HUD Text + camera.rect issue
« Reply #2 on: April 01, 2013, 03:21:17 PM »
You are a rock star!  8)

Here's what I did on line 89:
  1. pos.y = pos.y * .61f + .39f;
It's basically saying that my camera is 61% the size and 39% higher than where it expects it to be. Thanks!