Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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 /
  • Help Room /
avatar image
0
Question by Jonas_F · Nov 04, 2016 at 01:34 PM · uispritecanvaspanel

Adding a single colored 2d panel in a 3d game

So, here is what I want to achieve:

There are a couple of players, and each of them should have a name, an icon and some other information following the players model as a name tag. The name tag shall have a single colored background, that can be easily changed via script and should be resizable depending on the length of the players name. The name tag should be a child of the 3d model of the player.

Here's what I tried:

UI Panel - this has pretty much everything I need, but it can only be rendered on a Canvas. Since each tag should be a child of the player, this would mean a canvas for each player and I think that there are some major performance drawbacks if I do this.

Sprite with white image - works good, but you can't resize it properly. You can scale it, but this distorts all child elements like text, icons, etc

Plane - pretty much the same as the Sprite solution, and it feels... "dirty". This probably isn't what these planes are for.

My Question: Is there a simple way to add a 2d object with a recttransform component, that is completly filled with a single color, no matter how you resize it? Basically just like a UI panel that works outside of a canvas.

Thank you for your time.

Jonas

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
1

Answer by Zodiarc · Nov 04, 2016 at 01:37 PM

Did you try the world space canvas? You can do the "parenting" by a simple script which adjusts the world position of the panels to the player positions with some offset. This way you would have only 1 canvas.

Comment
Add comment · Show 1 · 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 Jonas_F · Nov 04, 2016 at 01:55 PM 0
Share

This might just do the trick for me. I will give it a try and tell you how it went.

Still, is there no solution to the general problem? It would be nice if you could resize sprites just like you can do with panels. Or use panels without a canvas. Well, maybe in Unity 6... :)

avatar image
1

Answer by tanoshimi · Nov 04, 2016 at 01:45 PM

"I think that there are some major performance drawbacks if I do this" -> What makes you think this? Have you tried profiling? If you've only got a couple of players there really should be no problem here - I have 30+ canvases in a scene with no performance hit (just remember to disable the graphic raycaster component if you don't need it)

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 Jonas_F · Nov 04, 2016 at 01:59 PM 0
Share

I think I read somewhere in a tutorial or forum post, that this is costly in terms of performance, but maybe this was because of the raycaster component. Does your game with 30+ Canvases run on mobile? Because the game I'm working on will be ported to a mobile version soon.

avatar image tanoshimi Jonas_F · Nov 04, 2016 at 02:02 PM 0
Share

It's not a mobile game, but I have no reason to believe it would be a huge problem on mobile.

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.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

IMAGE AND SPRITE SETTINGS 0 Answers

Scale all things inside UI canvas 0 Answers

How do I draw line on panels and canvas? 0 Answers

How to fix blur sprites and text in UI 0 Answers

Attach UI elements to screen corners 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges