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 Kafar · Jul 04, 2015 at 04:58 AM · c#guieditorgui

How to create elements array about all visible in GUI Editor?

Hi,

I need to create an array of all elements in GUI Editor (ie: Inspector and all elements, Hierarchy and all elements, Project and all elements, etc).

I need of this to cycle in array and find any element of GUIEditor I want and export in a text file for external elaborations.

It's possible? Please, sample code in c#.

Thanks

Comment
Add comment · Show 1
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 Kafar · Jul 06, 2015 at 07:44 AM 0
Share

Anyone can help me?

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by Immanuel-Scholz · Jul 06, 2015 at 10:58 AM

You cannot inspect the Editor - GUI directly, because there is nothing that could be inspected. The labels and everything is drawn "on the fly", thats why its also called "Immediate GUI".

What you can do, is to try to get to the same data source that the editor usually uses to draw its stuff.

  • For the Inspector, this would be the SerializedObject of the current selected objects. (You can enumerate its SerializedProperty using GetEnumerator()).

  • For the Project view, that are all assets in the directory of the current selected object (actually, its more complicated as you can select "folders only" which does not really appear in Unity's Selection.objects. But its good enough most of the time).

  • For the Hierarchy, that are all GameObjects and all their childs. You can iterate childs by calling transform.childCount and transform.GetChild(i) in a for-loop. Or you just do foreach (Transform child in transform) (which you should not do in Update-loops during runtime or common called functions as it allocates memory. But in editor-code its ok, I guess..)

Comment
Add comment · Show 9 · 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 Kafar · Jul 06, 2015 at 11:37 AM 0
Share

$$anonymous$$any thanks, and follow this way can I handle each object focused by mouse or keyboard?

avatar image Immanuel-Scholz · Jul 06, 2015 at 12:17 PM 0
Share

Getting the object that is selected in Hierarchy or Project window is dead-simple: Selection.activeObject (or Selection.objects if you want to support multi-selection).

However, getting the property in the Inspector window, that currently has the focus is nearly impossible. You can get its ControlID via GUI.keyboardControl or GUI.hotControl. But unfortunately, there is no sane way to get to the actual SerializedProperty from an internal ControlID.

avatar image Kafar · Jul 06, 2015 at 02:43 PM 0
Share

Ok, and about any custom data source installed from external assets? How to retrieve that too?

avatar image Immanuel-Scholz · Jul 08, 2015 at 10:16 AM 0
Share

What do you mean by that? What exactly do you want to iterate or retrieve?

avatar image Kafar · Jul 08, 2015 at 11:13 AM 0
Share

Basically, I need to make an asset and use it in edit mode for handle any field who user focus it with keyboard or mouse. About these fields I need to get the text name only. All except any object in scene. But if the user install a third part asset and this asset in edit mode create a cuatom inspector then my asset must handle any field into it too.

Show more comments

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Initialising List array for use in a custom Editor 1 Answer

Distribute terrain in zones 3 Answers

How to tell if any textField has keyboard focus in editor? 2 Answers

Multiple Cars not working 1 Answer

How to posistion GUI elements? 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