Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by Intervention · Dec 28, 2014 at 10:52 AM · panellayerdrawtooltip

UI Panel BringToFront

In the old GUI system for unity, there was GUI.BringToFront. Is there a way to do the equivalent (telling the UI drawing system to draw a particular element in front of all others) for UI elements?

Googling around for this, I am only finding references to a the old GUI system.

I am building an inventory system that has tooltips, where my tooltip is a UI Panel with some images/text. I can draw the panel when I want, but it is hidden by other UI elements that are below it in my project hierarchy.

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

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by TonyGon · Jul 03, 2016 at 12:41 PM

Programmatically you can achieve this by getting the RectTransform of your element and setting it as last sibling in the hierarchy, i.e.

 RectTransform theRectTransform;
 ...
 theRectTransform = transform as RectTransform; // Cast it to RectTransform
 panelRectTrafo.SetAsLastSibling(); // Make the panel show on top.

This works since the elements are rendered in the order they appear in the hierarchy, and setting the SetAsLastSibling() method is equivalent to dragging the element in the editor below other elements, which in turn makes it render on top.

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 marcin107 · Aug 08, 2017 at 05:03 PM 0
Share

I couldn't find any better answer, thanks!

avatar image
0

Answer by alok-kr-029 · Dec 28, 2014 at 01:58 PM

The UI element you want to keep above inside the panel just drag and drop that element at bottom of the hierarchy inside the panel all the ui element must be child of the panel

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 Intervention · Dec 28, 2014 at 06:21 PM 0
Share

Each of my inventory slots have a tooltip panel as children. I instantiate each of the slots at runtime and add them to a 'background' container panel, resulting in a hierarchy that has a bunch of slots at the same hierarchical level each with a child tooltip. This means that for each slot that is not the last instantiated slot, there are slots below it on the heirarchy, and their panels are diplayed in front of the tooltip panel for the slot above it.

Perhaps a better solution for me would be to have a tooltip prefab placed at the bottom of my hierarchy and simply instantiate it and position it in 2D space over the icon I mouse over, rather than each slot having their own tooltip.

This said, I can imagine situations where it would be desirable to be able to set the rendering layer at runtime, and I'm confident there is a way to do this - just haven't been able to find out how. It seems with a newly designed UI system, something analogous to 'bring this UI element to the front of all the others' would be a natural thing to include in the UI API.

avatar image Intervention · Dec 28, 2014 at 07:46 PM 0
Share

What I've done is created my tooltip panel at the bottom of the Canvas hierarchy (so that it renders on top of all other UI elements), set it to inactive (since it isn't suppose to be displayed by default), dragged it into a GameObject variable in my Inventory script, then when I instantiate the individual inventoryslot objects from within my Inventory script, I provide a reference to the Tooltip panel to each slot.

I am still interested in learning about a way to programatically bring a UI element to the front of the screen. It certainly seems like this would be a normal, common thing to do.

avatar image
0

Answer by aal-ok · Jul 03, 2016 at 02:01 PM

or, you can just change the layer of the image to bring it to front, 1 for front and so on

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

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

6 People are following this question.

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

Related Questions

Combining Mesh changes Draw Order? 3 Answers

How to draw in specific panel? 0 Answers

Drawing a 3D object javascipt 0 Answers

to draw a health bar 2 Answers

How to draw an outline around multiple hexagon game objects? 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