Search Unity

int2 causes constant flickers

Discussion in 'UI Toolkit' started by tertle, Apr 9, 2019.

  1. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    Have a very simple editor and it just constantly flickers. Video:


    Unity version 2019.2.0a9, caused by this
    new PropertyField(int2)


    Full source

    Code (CSharp):
    1.  
    2. // <copyright file="VisionInstallerEditor.cs" company="BovineLabs">
    3. // Copyright (c) BovineLabs. All rights reserved.
    4. // </copyright>
    5.  
    6. namespace BovineLabs.Vision.Editor
    7. {
    8.     using UnityEditor;
    9.     using UnityEditor.UIElements;
    10.     using UnityEngine;
    11.     using UnityEngine.UIElements;
    12.  
    13.     /// <summary>
    14.     /// The VisionInstallerEditor.
    15.     /// </summary>
    16.     [CustomEditor(typeof(VisionInstaller))]
    17.     public class VisionInstallerEditor : Editor
    18.     {
    19.         /// <inheritdoc />
    20.         public override VisualElement CreateInspectorGUI()
    21.         {
    22.             var container = new VisualElement();
    23.             this.CreatePropertyFieldWithCheck(container, "size");
    24.             this.CreatePropertyFieldWithCheck(container, "scale");
    25.             this.CreatePropertyFieldWithCheck(container, "revealOpacities");
    26.             this.CreatePropertyFieldWithCheck(container, "filterMode");
    27.  
    28.             var editorFoldout = new Foldout { text = "Editor", value = false };
    29.             container.Add(editorFoldout);
    30.             this.CreatePropertyFieldWithCheck(editorFoldout, "hideFog");
    31.  
    32.             return container;
    33.         }
    34.  
    35.         private void CreatePropertyFieldWithCheck(VisualElement container, string propertyPath)
    36.         {
    37.             var property = this.serializedObject.FindProperty(propertyPath);
    38.             if (property == null)
    39.             {
    40.                 Debug.LogError($"Property {propertyPath} was not found: renamed or removed");
    41.                 return;
    42.             }
    43.  
    44.             container.Add(new PropertyField(property));
    45.         }
    46.     }
    47. }
    48.  
    49.  
    50.  
     
  2. etienne_phil_unity

    etienne_phil_unity

    Unity Technologies

    Joined:
    Jan 15, 2019
    Posts:
    16
    Hello, could you also post VisionInstaller's code? The part where the properties are declared?
     
  3. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    Sure

    Code (CSharp):
    1. // <copyright file="VisionInstaller.cs" company="BovineLabs">
    2. //     Copyright (c) BovineLabs. All rights reserved.
    3. // </copyright>
    4.  
    5. namespace BovineLabs.Vision
    6. {
    7.     using System;
    8.     using System.Collections.Generic;
    9.     using BovineLabs.Common.Initialization;
    10.     using BovineLabs.Common.Variables;
    11.     using Unity.Entities;
    12.     using Unity.Mathematics;
    13.     using UnityEngine;
    14.  
    15.     /// <summary>
    16.     ///     Shared settings for fog of war and related systems.
    17.     /// </summary>
    18.     [CreateAssetMenu(fileName = "VisionInstaller", menuName = "BovineLabs/Installers/Vision")]
    19.     public class VisionInstaller : Installer
    20.     {
    21.         [SerializeField]
    22.         private int2 size = new int2(512, 512);
    23.  
    24.         [SerializeField]
    25.         private int2 offset = new int2(0, 0);
    26.  
    27.         [SerializeField]
    28.         [Range(1, 8)]
    29.         private int scale = 1;
    30.  
    31.         [SerializeField]
    32.         private Color32 revealOpacities = new Color32(255, 127, 26, 255);
    33.  
    34.         [SerializeField]
    35.         private FilterMode filterMode = FilterMode.Bilinear;
    36.  
    37. #if UNITY_EDITOR
    38.         [SerializeField]
    39.         private BoolVariable hideFog = default;
    40. #endif
    41.  
    42.         /// <inheritdoc />
    43.         public override void Initialize(World world, List<Type> systems)
    44.         {
    45.             world.AddSystem(new FogOfWarSystem(this.size, this.offset, this.scale, this.revealOpacities));
    46.             world.AddSystem(new FogOfWarActiveSystem(this.size, this.offset, this.scale, this.filterMode)
    47.             {
    48. #if UNITY_EDITOR
    49.                 HideFog = this.hideFog
    50. #endif
    51.             });
    52.             world.AddSystem(new RevealedSystem(this.size, this.scale));
    53.         }
    54.     }
    55. }
    BoolVariable is a custom scriptable object that I have a custom property drawer for. I thought it might be responsible but the issue persists with it removed.

    I should add I've since been able to get an exception thrown on occasion if I try to drag the input fields.

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. UnityEditor.EditorGUI.HasKeyboardFocus (System.Int32 controlID) (at C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:2001)
    3. UnityEditor.EditorGUI.DoNumberField (UnityEditor.EditorGUI+RecycledTextEditor editor, UnityEngine.Rect position, UnityEngine.Rect dragHotZone, System.Int32 id, System.Boolean isDouble, System.Double& doubleVal, System.Int64& longVal, System.String formatString, UnityEngine.GUIStyle style, System.Boolean draggable, System.Double dragSensitivity) (at C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:2015)
    4. UnityEditor.EditorGUI.DoLongField (UnityEditor.EditorGUI+RecycledTextEditor editor, UnityEngine.Rect position, UnityEngine.Rect dragHotZone, System.Int32 id, System.Int64 value, System.String formatString, UnityEngine.GUIStyle style, System.Boolean draggable, System.Double dragSensitivity) (at C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:1988)
    5. UnityEditor.EditorGUI.LongFieldInternal (UnityEngine.Rect position, UnityEngine.GUIContent label, System.Int64 value, UnityEngine.GUIStyle style) (at C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:2307)
    6. UnityEditor.EditorGUI.LongField (UnityEngine.Rect position, UnityEngine.GUIContent label, System.Int64 value, UnityEngine.GUIStyle style) (at C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:7035)
    7. UnityEditor.EditorGUI.LongField (UnityEngine.Rect position, UnityEngine.GUIContent label, System.Int64 value) (at C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:7030)
    8. UnityEditor.EditorGUI.DefaultPropertyField (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:6063)
    9. UnityEditor.PropertyHandler.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren, UnityEngine.Rect visibleArea) (at C:/buildslave/unity/build/Editor/Mono/ScriptAttributeGUI/PropertyHandler.cs:149)
    10. UnityEditor.PropertyHandler.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren) (at C:/buildslave/unity/build/Editor/Mono/ScriptAttributeGUI/PropertyHandler.cs:106)
    11. UnityEditor.EditorGUI.PropertyFieldInternal (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren) (at C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:6041)
    12. UnityEditor.EditorGUI.PropertyField (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren) (at C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:7402)
    13. UnityEditor.EditorGUI.PropertyField (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:7397)
    14. UnityEditor.EditorGUI.MultiPropertyField (UnityEngine.Rect position, UnityEngine.GUIContent[] subLabels, UnityEditor.SerializedProperty valuesIterator, UnityEditor.EditorGUI+PropertyVisibility visibility, System.Single labelWidth, System.Boolean[] disabledMask) (at C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:4251)
    15. UnityEditor.EditorGUI.MultiPropertyField (UnityEngine.Rect position, UnityEngine.GUIContent[] subLabels, UnityEditor.SerializedProperty valuesIterator) (at C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:4229)
    16. UnityEditor.EditorGUI.MultiPropertyField (UnityEngine.Rect position, UnityEngine.GUIContent[] subLabels, UnityEditor.SerializedProperty valuesIterator, UnityEngine.GUIContent label) (at C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:4224)
    17. Unity.Mathematics.Editor.PrimitiveVectorDrawer.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at Library/PackageCache/com.unity.mathematics@1.0.0-preview.1/Unity.Mathematics.Editor/PrimitiveVectorDrawer.cs:73)
    18. UnityEditor.PropertyDrawer.OnGUISafe (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at C:/buildslave/unity/build/Editor/Mono/ScriptAttributeGUI/PropertyDrawer.cs:23)
    19. UnityEditor.PropertyHandler.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren, UnityEngine.Rect visibleArea) (at C:/buildslave/unity/build/Editor/Mono/ScriptAttributeGUI/PropertyHandler.cs:139)
    20. UnityEditor.PropertyHandler.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren) (at C:/buildslave/unity/build/Editor/Mono/ScriptAttributeGUI/PropertyHandler.cs:106)
    21. UnityEditor.PropertyHandler.OnGUILayout (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren, UnityEngine.GUILayoutOption[] options) (at C:/buildslave/unity/build/Editor/Mono/ScriptAttributeGUI/PropertyHandler.cs:208)
    22. UnityEditor.EditorGUILayout.PropertyField (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren, UnityEngine.GUILayoutOption[] options) (at C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:9352)
    23. UnityEditor.EditorGUILayout.PropertyField (UnityEditor.SerializedProperty property, System.Boolean includeChildren, UnityEngine.GUILayoutOption[] options) (at C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:9346)
    24. UnityEditor.UIElements.PropertyField.<Reset>m__0 () (at C:/buildslave/unity/build/Editor/Mono/UIElements/Controls/PropertyField.cs:105)
    25. UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize) (at C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:281)
    26. UnityEditor.UIElements.Tooltip:SetTooltip(Single, Single)
    27.  
    28.  
    and I'm using the latest version, at least it was as of checking yesterday, of the mathematics package. "com.unity.mathematics": "1.0.0-preview.1",
     
  4. etienne_phil_unity

    etienne_phil_unity

    Unity Technologies

    Joined:
    Jan 15, 2019
    Posts:
    16
    I haven't had success reproducing this, could you log a bug with a small repro project? Thanks!
     
  5. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    I've submitted a bug report with a simpe project but I'll post the project here as well. (I'll add the bug report # when I get it.)

    Unity Version 2019.2.0a9

    -edit-

    #1145908 was reproduced by Unity QA
     

    Attached Files:

    Last edited: Apr 17, 2019