[Editor] Buttons in Inspector

Hi there !

How can i make buttons for inspector like this ?

3831055--323242--upload_2018-10-28_23-8-44.png

3831382--323281--upload_2018-10-29_1-2-53.png
Is that text ?

I think you’re missing what OP wants…

@ , what nature of the buttons is it you’re not able to make? Is it any button whatsoever, or is it the fact that they are radio buttons, or is it that they have images instead of text for the buttons?

If you download the (now official) text mesh pro package from the package manager, you can look at the source code for their inspectors. They have the exact same kinds of symbols for alignment, and it seems like they’re using:

  • EditorGUILayout.GetControlRect to reserve a rect
  • GUI.SelectionGrid for the buttons
  • a custom GUIStyle to make the buttons look right.

The interesting file is TextMesh Pro/Scripts/Editor/TMP_EditorPanel.

2 Likes

I create own class:

 namespace UnityEngine.UI.Extensions {

    public class ModernText : Text , IPointerClickHandler {
        //...
    }
   
}
namespace UnityEngine.UI.Extensions {

    [CustomEditor(typeof(ModernText))]
    public class ModernTextEditor : Editor {

        public override void OnInspectorGUI() {
            // ...
        }
       
}

I want show property of Text “alignment” in inspector of my class.