• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Excalibera · Nov 23, 2013 at 02:40 PM · cameraguihud

Runescape style window?

alt text

How would I go about making this? I can do all the HUD etc, but how would I make the actual game above the chat and to the left of inventory / map. As it's enclosed? Any idea how to do this even if it's simple, then please help, I'm stuck at this. Thanks in advance!

EDIT: Haha, figured something out that'll do. I put the scripts on a gameobject instead of the camera, thought they had to be on the camera to be shown. If there's a better way for this let me know ;p

111221001829.png (350.4 kB)
Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image luckruns0ut · Nov 23, 2013 at 02:49 PM 0
Share

I don't understand what you want. Are you looking to have the game's viewport moved into the upper left corner so that there is room for the inventory and chat at the bottom right? You could easily do that with the Camera's Inspector options.

avatar image Excalibera · Nov 23, 2013 at 02:58 PM 0
Share

I made a gameobject and put the GUI scripts onto it, then scaled the camera to fit correctly. What my problem is right now, is that when you click out of the camera (chat for example), it still moves with my click to move script.

/

it still acts as if I'm clicking inside the camera

avatar image luckruns0ut · Nov 23, 2013 at 03:02 PM 0
Share

Assuming your game window will be a fixed size, can't you just check the mouse coordinates before running the click-to-move code to make sure that they are within the viewport?

avatar image Excalibera · Nov 23, 2013 at 03:04 PM 0
Share

I am new to javascript and so far I have only 'fully' got the hand of unity's GUI system, said in another way, I wouldn't be able to code that since I dont know how to, yet. If I knew how to, I am sure I could use that.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Tomer-Barkan · Nov 23, 2013 at 03:44 PM

You can set variable "Viewport Rect" either from the inspector, or from code. This specify whit section of the screen the given camera will occupy. You can do this to limit the output of the camera as you describe, or even for split-screen multiplayer.

BTW: if you want clicks outside of the camera to be ignored by certain scripts, all you have to do is check the mouse position and whether it is within the viewport of the camera or not.

 Rect camViewport = Camera.main.rect;
 Vector3 mousePos = Input.mousePosition;
 if (mousePos.x >= camViewport.xMin && mousePos.x <= camViewport.xMax && mousePos.y >= camViewport.yMin && mousePos.y <= camViewport.yMax) {
     // do something only when mouse is within the main game window
 }

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Excalibera · Nov 23, 2013 at 04:15 PM 0
Share

Ah, so I put this into a java script, add the scripts with GetComponent, and those added with GetComponent wont do anything outside the camera?

avatar image Tomer-Barkan · Nov 24, 2013 at 08:36 AM 0
Share

No, not exactly. This is just the frame of the script. Inside the if statement you have to put your own code, the one you want to execute only when the mouse pointer is within the camera viewport.

For example, if you want to print "Hello" in the log, but only when the user clicks the mouse button within the main camera view:

 if (mousePos.x >= camViewport.x$$anonymous$$in && mousePos.x <= camViewport.x$$anonymous$$ax && mousePos.y >= camViewport.y$$anonymous$$in && mousePos.y <= camViewport.y$$anonymous$$ax) {
     if (Input.Get$$anonymous$$eyDown($$anonymous$$eycode.$$anonymous$$ouse0) {
         Debug.Log("Hello");
     }
 }

So we check that the mouse position is within the window, then we check that the mouse button was pressed, then we print "Hello" to the debug log.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

18 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multi Camera HUD buttons not working. 1 Answer

Cameras Switch Based On Button Click 1 Answer

Detecting camera viewport on mouse down? 1 Answer

I need to remove the GUI from this camera script, but I don't know how. 2 Answers

Best way to create mini hp-bars for enemies. 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges