Search Unity

Does VisualElmenet.tooltip work at runtime?

Discussion in 'UI Toolkit' started by Ryuuguu, Aug 7, 2020.

  1. Ryuuguu

    Ryuuguu

    Joined:
    Apr 14, 2007
    Posts:
    391
    I made a minimal example for testing at runtime. The button does change visually when clicked so the mouse is detected but no tooltip pops up. Am I missing some code? Any suggestions?

    Code (CSharp):
    1. void Start() {
    2.         var uiDoc= GetComponent<UIDocument>();
    3.         var rootVE = uiDoc.rootVisualElement;
    4.        
    5.         var ve2 = new Button();
    6.        
    7.         ve2.style.width = 200;
    8.         ve2.style.height = 200;
    9.         ve2.style.backgroundColor = Color.black;
    10.  
    11.         ve2.tooltip = "A toolTip";
    12.        
    13.         rootVE.Add(ve2);  
    14.     }
     
  2. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    700
    Ryuuguu likes this.
  3. Ryuuguu

    Ryuuguu

    Joined:
    Apr 14, 2007
    Posts:
    391
    Thank for the answer & link.