Search Unity

Bug IsDelayed property affects SetValueWithoutNotify

Discussion in 'UI Toolkit' started by Kirbyrawr, Aug 19, 2019.

  1. Kirbyrawr

    Kirbyrawr

    Joined:
    Jul 23, 2012
    Posts:
    945
    Description
    If an IntegerField have the property
    isDelayed
    set to true, SetValueWithoutNotify won't have any effect.

    Unity Version

    2019.3.0a12

    Reproducibility Rate

    10/10

    Additional Info:
    If you remove the
    isDelayed
    property it will work as usual.

    Workaround:
    Code (CSharp):
    1. var integerField = root.Q<IntegerField>("int-field");
    2. integerField.isDelayed = false;
    3. integerField.SetValueWithoutNotify(2);
    4. integerField.isDelayed = true;
    Test.cs
    Code (CSharp):
    1. using UnityEditor;
    2. using UnityEngine;
    3. using UnityEngine.UIElements;
    4. using UnityEditor.UIElements;
    5.  
    6.  
    7. public class Test : EditorWindow
    8. {
    9.     [MenuItem("Window/UIElements/Test")]
    10.     public static void ShowExample()
    11.     {
    12.         Test wnd = GetWindow<Test>();
    13.         wnd.titleContent = new GUIContent("Test");
    14.     }
    15.  
    16.     public void OnEnable()
    17.     {
    18.         // Each editor window contains a root VisualElement object
    19.         VisualElement root = rootVisualElement;
    20.  
    21.         // Import UXML
    22.         var visualTree = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/Editor/Test.uxml");
    23.         VisualElement labelFromUXML = visualTree.CloneTree();
    24.         root.Add(labelFromUXML);
    25.  
    26.         var integerField = root.Q<IntegerField>("int-field");
    27.         integerField.isDelayed = true;
    28.         integerField.SetValueWithoutNotify(2);
    29.     }
    30. }
    Test.uxml
    Code (CSharp):
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <engine:UXML
    3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    4.     xmlns:engine="UnityEngine.UIElements"
    5.     xmlns:editor="UnityEditor.UIElements"
    6.     xsi:noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd"
    7. >
    8.     <editor:IntegerField name="int-field" label="Int Field"/>
    9. </engine:UXML>
     
    Last edited: Aug 19, 2019
  2. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    780
    Hello,

    Thanks for the detailed report. Can you please submit this in Unity via the bug reporter (Help > Report a bug...).

    This way our QA team can identify if it is a regression and you can a notification when it is fixed.

    Thank you
     
    Kirbyrawr likes this.
  3. Kirbyrawr

    Kirbyrawr

    Joined:
    Jul 23, 2012
    Posts:
    945
    Hi, thank you.

    Case 1178168
    http://fogbugz.unity3d.com/default.asp?1178168_kp748u2qtj9si6hc