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
1
Question by TurboHermit · Sep 18, 2013 at 12:33 PM · editorpositioncustomrectpopup

Inspector Rect position

Hi, I just began using custom editor scripts to make my game scripts more accessible to my designers/users. However I've come across a bit of a problem. Like I said Im making the actual scripts somewhat more organized to handle, so this is: all the variables in the Inspector on that specific component.

Im using a Popup for certain variables too, and they need a Rect for position and scale and such. Is there any way to find the position of the component/script in the inspector or a way to dynamically see where the component starts?

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

Answer by Bunny83 · Sep 18, 2013 at 12:55 PM

Right after you drawn a GUI element you can use GUILayoutUtility.GetLastRect to get the Rect of the last element.

Note: You can only get the Rect inside the Repaint event.

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 TurboHermit · Sep 18, 2013 at 01:43 PM 0
Share

GUILayoutUtility.GetLastRect works even though you haven't used a Rect yet? So it just grabs the Inspector's Rect by default?

avatar image
0

Answer by Pryme8 · Oct 30, 2015 at 09:10 PM

@Danzou Also you can load the default game Inspector window into a EditorWindow type by finding all of the EditorWindows OnEnable and pushing the results through a loop looking for "UnityEditor.InspectorWindow" as the title of the EditorWindows....

Keep in mind in this example it is attached to a normal MonoBehavior Script, which would need to be loaded with the script that controls your user interface so that your variable is nice and fresh, that is why there is the command to execute in edit more; this would be unnecessary on a edtior script, but you would have to decide to do it on Init, or on Enable...

Example:

 using UnityEditor;
 using UnityEditorInternal;
 
 
 [ExecuteInEditMode]
 
 public class someClass : MonoBehaviour {
 
     public static EditorWindow inspector;
 
     public void OnEnable(){
         EditorWindow[] windows = Resources.FindObjectsOfTypeAll<EditorWindow> () as EditorWindow[];
         
         foreach (EditorWindow ew in windows) {
             if(ew.title == "UnityEditor.InspectorWindow"){
                 inspector = ew;
             }
         }
         }
 }


Should get you pointed in the correct direction.... and will give you a global EditorWindow that is a reference to the default inspector window. I am able to cover the entire inspector window with my own custom window that moves with the Default Inspector and resized to its same scale.

I know its prolly not the best way to do this (in fact just using the default GUI rendering area not a custom window is the convention to make something like that, but i had my reasoning for doing it. )

If you need anymore help in this matter let me know.

Also, im sure you could pull it off with

?Shotty Example?:

          EditorWindow inspector= Resources.FindObjectsOfTypeAll<EditorWindow> ("UnityEditor.InspectorWindow") as EditorWindow;

but I have never tried... Im not sure if the declaration after the type is for title or for name or for type as a string blah blah in fact Im gonna go look it up now, cause I feel like a dumb dumb not knowing what that is actually calling...

Both of those are written off the top of my head but should drop no errors, I know the top one works.

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

18 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

Related Questions

How can I set the initial position of EditorGUILayout.Popup ? 0 Answers

Inspector Popup format to look like tag or layer popup 1 Answer

Editor Window with settings and Asset Creation 1 Answer

Gibt es eine Lösung/Einstellung für: Hierarchy Custom / My Sort? 1 Answer

Custom Editor: show asset folders in ObjectField 2 Answers


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