During the past several months I've done a bit of work extending the Unity3D editor to create custom editor functionality for my upcoming game. Unity makes it ridiculously easy to implement custom functionality in the editor, however their documentation can leave something to be desired. One of the hidden nuggets I found is EditorGUIUtility.LookLikeControls() , which exposes custom formatting for certain EditorGUILayout elements.
Here's an example of using EditorGUILayout.EnumPopup() and EditorGUILayout.LabelField() to show some enum and string values. As you can see the description label on the left is cut off, which makes this GUI very unusable. EditorGUIUtility.LookLikeControls() lets you change the default pixel size of one or both of the content display fields for these methods, so you can make your GUI's much more readable.
Here's the same menu using EditorGUIUtility.LookLikeControls(250), which expands the first content zone to 250 pixels, and provides a nice amount of space to clearly mark the inputs for the menu. And as you can see at the bottom, calling EditorGUIUtility.LookLikeControls() with no params will restore the GUI system to the default layout for these elements.
No comments:
Post a Comment