• 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
1
Question by Myrion · Mar 05, 2015 at 01:21 AM · guiuiguilayout

How to position a GUI-Element relative to a game object?

So I'm getting started developing a little game in Unity, and I'd like to make it so that if I click on a character on screen, a menu pops up next to the character with possible actions.

I have messed around a bit with several options: GUILayout, GUI, UI with Canvas. I haven't tried just making gameobjects looking like such a menu and manipulating those, yet. I can position the menu the way I want to by using GUI (with new Rect(gameobject.x+offset etc.)), but not using GUILayout or the canvas-based UI.

Now, I could just use GUI, but everyone seems to warn against that, and it's called Legacy in Unity's documentation. So I hesitate before committing to that choice.

It's starting to look to me that I should probably "fake" the UI using gameobjects, because everything else is either very cumbersome or actively discouraged.

What is the optimal or at least the idiomatic way of doing something like this?

Comment
Add comment
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

0 Replies

· Add your reply
  • Sort: 

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

2 People are following this question.

avatar image avatar image

Related Questions

Make children of a Layout Group fit their respective sizes (confusing docs) 1 Answer

Help with GUILayout and tooltip(C#) 1 Answer

How to make a simple gui list 0 Answers

Make GUILayout horizontal first, then vertical? (C#) 3 Answers

Does GUIStyle.CalcSize harm the performance? 1 Answer

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