Search Unity

Question Underscore and other symbols hides text in popup: _ # % (hotkey symbols?)

Discussion in 'Immediate Mode GUI (IMGUI)' started by DCoin, Feb 24, 2023.

  1. DCoin

    DCoin

    Joined:
    Feb 11, 2018
    Posts:
    3
    Hey
    I am trying to use EditorGUILayout.Popup to show a list of options that can be edited by the user and may include symbols (_ # % etc.).
    The problem is that these symbols sometimes hides words in the popup menu. Specifically it seems to hide the last word if it starts with such a symbol and is preceded by a space for example "Test _hidden" will show as "Test" in the popup.

    Here is my test code:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3. using System.Linq;
    4.  
    5. [CustomPropertyDrawer(typeof(int))]
    6. public class SiblingGroupDrawer: PropertyDrawer
    7. {
    8.     static string[] test = new string[] { "test _thisIsHidden", " _thisBecomesLine", "_thisWorksFine", "wd _notHidden withFollowUp" };
    9.     static GUIContent[] test2 = test.Select( s => new GUIContent(s) ).ToArray();
    10.     public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    11.     {
    12.         int oldIndex = property.intValue;
    13.         int newIndex = EditorGUILayout.Popup(label, oldIndex, test2);
    14.         if (newIndex != oldIndex)
    15.         {
    16.             property.intValue = newIndex;
    17.         }
    18.     }
    19. }
    And it shows like the this:
    test.png

    Do you know what is going on and how I can prevent this?

    I am testing in Unity 2022.2.6f1
     
    Last edited: Feb 24, 2023