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 RedSandStudios · Feb 19, 2014 at 04:14 PM · editorwindowhierarchycustom editorhud

Custom HUD Hierarchy in Editor Window

I am developing a game using Unity and since the beginning it was clear to me that I would implement a custom way to draw the HUD, which I have achieved easily, using a hierarchical structure of HUDObjects. The way I have been implementing this structure is simply storing a list of children HUDObjects in each HUDObject and then recursively drawing them. This has worked out fine for me so far, but as the project is growing in size, I am finding it more and more tedious and confusing to navigate to each individual HUDObject to traverse the HUD tree.

I have always been impressed by Unity's extendability, particularly with the Editor, so I looked into a creating a custom HUD Editor Window. I found that I could certainly draw the hierarchy out, using a series of Foldouts, but it didn't give me the level of interactivity I wanted. What I basically am looking to achieve the Unity's Scene Hierarchy Window, but for my custom HUDObjects, where I can drag them around to reparent them in the heirarchy. I am simply wondering if this is at all possible and if someone could at least point me in the right direction to go with this, I would be very grateful.

Thanks for reading my wordy question!

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
0
Best Answer

Answer by RedSandStudios · Feb 20, 2014 at 12:37 PM

So as far as I can tell, there is no way to directly imitate the Hierarchy view. However, using a combination of a GUI drag-drop script by AngryAnt and Unity's DragAndDrop class I have managed to achieve something functional. I use AngryAnt's script to draw the actual hierarchy. It's a very simple system which uses the Unity Event functionality to detect when a drag is occurring and simply draw the offending draggable object relative to the mouse position. Because my HUDObjects are ScriptableObjects underneath, I store them as actual assets in the project, so to get them from the Project view into this hierarchy view I had to use Unity's DragAndDrop class. Relatively simple to use, I only use the AcceptDrag function, then simply iterate over the DragAndDrop.objectReferences and add each HUDObject into the hierarchy.

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
avatar image
0

Answer by MakeCodeNow · Feb 19, 2014 at 04:41 PM

I just went through this for my latest asset store product where I wanted to have a tree control. It's totally possible, but you have to do almost everything yourself. There's no built in tree control widget, and even foldouts only go so far. I think there is a tree control widget you can buy on the asset store, but last I checked it was more targeted to in-game GUIs.

If it's just the number/complexity of the objects in the hierarchy that's a problem, you might find it more productive to just use the filtering/search options built into the scene hierarchy view.

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 RedSandStudios · Feb 19, 2014 at 04:57 PM 0
Share

Perhaps I should have waited slightly longer to not post this question as I have actually just found two answers! It seems Unity provides a DragAndDrop class for use with OnGUI, where you can set and get objects with the drag. Also, some clever guy called AngryAnt has put together a GUI drap-drop script. I will update this later with an answer to which is easiest to use/most useful.

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

19 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 avatar image

Related Questions

Popup options not changing in custom editor script 0 Answers

What is the best way to draw icons in Unity's Hierarchy window? 1 Answer

DragAndDrop Problems, Returns wrong GameObject! 1 Answer

Selecting an object in the scene would assign it to an empty gameobject in the inspector 1 Answer

Custom Editor Window Nodes Unresponsive Button 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