• 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 jb777 · Jun 07, 2011 at 01:37 PM · gameobject3dhealthprogress-barguilayer

3d Object in GUI Layer

Is it possible to put a 3D Object on the GUI Layer?

I made a life bar out of 3D heart shapes. I scripted them and added them as a GameObject. Then I parented the heart GameObjects to the mainCamera. It works fine but there are some flaws with this approach. I have to manually position the hearts for each scene.

Is it possible to put the heart GameObjects on the GUI Layer instead? It would be a simpler approach.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by flaminghairball · Jun 07, 2011 at 02:06 PM

You have a couple of options:

1) If you have Pro, you can use a rendertexture. 2) If you don't have Pro, you can put the hearts in another layer that is blocked on the main camera, and then use a secondary camera to render the hearts. Take a look at the 'normalized viewport' and culling options of the camera class.

Let me know if this is unclear.

Comment
Add comment · Show 7 · 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 jb777 · Jun 07, 2011 at 03:25 PM 0
Share

Thanks. Got it working. Never thought to use more than one camera.

avatar image Chris D · Jun 07, 2011 at 03:47 PM 0
Share

Why the need for the second camera? Couldn't you just parent the hearts directly to the main one and create a prefab out of it (to avoid repositioning every time), or is that the problem?

avatar image flaviusxvii · Jun 07, 2011 at 03:50 PM 0
Share

You could do that too.. but you'd need to carefully control render order, and probably either disable depth testing or clear the depth buffer before drawing the hearts.

avatar image Chris D · Jun 07, 2011 at 04:04 PM 0
Share

Ah, ok, I think I understand now. Looking at the camera documentation, it seems there's a lot there to learn :D

avatar image flaviusxvii · Jun 07, 2011 at 04:07 PM 0
Share

As much as there is Unity is still like a big fluffy cloud of joy compared to really doing it yourself. I've implemented cameras and quaternions and transforms and whatnot. It's a great learning experience but it's nice to have all this great stuff more or less solid and ready to go.

Show more comments
avatar image
2

Answer by flaviusxvii · Jun 07, 2011 at 02:06 PM

I'd render them with a second camera. Give it a limited viewport and disable any kind of screen clearing. It'll just draw the hearts over the top of whatever you have on your screen.

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 jb777 · Jun 07, 2011 at 03:27 PM 0
Share

Thanks. Wish I could give out two check marks but FlamingHairball's answer had a bit more info.

avatar image flaviusxvii · Jun 07, 2011 at 03:52 PM 1
Share

No problem. I don't ever really give detailed answers. I just like to steer people towards what they need to learn to solve their own problems.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to detect if a GameObject is hit by a Spotlight 1 Answer

Basic Health Bar Display Problem 1 Answer

Creating a Lifebar with simple GUI in C# 3 Answers

How to Make a simple Knot with Rope simulation 0 Answers

Health Bar to Render On Top 2 Answers

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