Search Unity

Exceptions in drawing GUI for Standard Analytics Event

Discussion in 'Unity Analytics' started by ferretnt, Jul 27, 2018.

  1. ferretnt

    ferretnt

    Joined:
    Apr 10, 2012
    Posts:
    412
    In quite a few cases, the Unity Analytics Tracker GUI "breaks" if it is referencing, for example a field on an object as a dynamic parameter, and then the source code for the object changes such that that parameter no longer exists.

    For example, suppose we have a GameObject, and we're logging its "DriveableObject.driveableName". If the member driveableName is then renamed to e.g. drivableIdentifier, then the Analytics tracker refresh throws an exception at TrackableField.cs:48.

    Is there a quick way to work around this? The problem is that any of our engineers can recognize and fix this, but our designers can't, and the Standard Events are kind of about keeping the engineers independent from Analytics implementation.

    We're using Unity 2017.4 (.6 or something, typically whatever's latest) and the current Asset Store package. We can't move away from the package as we need to modify the standard events source code ourselves in a number of ways.

    NullReferenceException: Object reference not set to an instance of an object
    UnityEngine.Analytics.Experimental.Tracker.TrackableField.GetValue () (at Assets/Services/Analytics/Tracker/TrackableProperty/TrackableField.cs:48)
    UnityEngine.Analytics.Experimental.Tracker.ValueProperty.IsValid () (at Assets/Services/Analytics/Tracker/TrackableProperty/ValueProperty.cs:91)
    UnityEngine.Analytics.Experimental.Tracker.StandardEventPayloadDrawer.ParametersGUI (Rect position, UnityEditor.SerializedProperty property, Boolean draw) (at Assets/Services/Analytics/Tracker/Payload/Editor/StandardEventPayloadDrawer.cs:300)
    UnityEngine.Analytics.Experimental.Tracker.StandardEventPayloadDrawer.OnGUI (Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, Boolean draw) (at Assets/Services/Analytics/Tracker/Payload/Editor/StandardEventPayloadDrawer.cs:71)
    UnityEngine.Analytics.Experimental.Tracker.StandardEventPayloadDrawer.GetPropertyHeight (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at Assets/Services/Analytics/Tracker/Payload/Editor/StandardEventPayloadDrawer.cs:420)
    UnityEditor.PropertyDrawer.GetPropertyHeightSafe (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at /Users/builduser/buildslave/unity/build/Editor/Mono/ScriptAttributeGUI/PropertyDrawer.cs:36)
    UnityEditor.PropertyHandler.GetHeight (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, Boolean includeChildren) (at /Users/builduser/buildslave/unity/build/Editor/Mono/ScriptAttributeGUI/PropertyHandler.cs:216)
    UnityEditor.PropertyHandler.OnGUILayout (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, Boolean includeChildren, UnityEngine.GUILayoutOption[] options) (at /Users/builduser/buildslave/unity/build/Editor/Mono/ScriptAttributeGUI/PropertyHandler.cs:201)
    UnityEditor.EditorGUILayout.PropertyField (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, Boolean includeChildren, UnityEngine.GUILayoutOption[] options) (at /Users/builduser/buildslave/unity/build/Editor/Mono/EditorGUI.cs:8116)
    UnityEditor.EditorGUILayout.PropertyField (UnityEditor.SerializedProperty property, UnityEngine.GUILayoutOption[] options) (at /Users/builduser/buildslave/unity/build/Editor/Mono/EditorGUI.cs:8098)
    UnityEngine.Analytics.Experimental.Tracker.AnalyticsEventTrackerEditor.PayloadGUI () (at Assets/Services/Analytics/Tracker/Editor/AnalyticsEventTrackerEditor.cs:57)
    UnityEngine.Analytics.Experimental.Tracker.AnalyticsEventTrackerEditor.OnInspectorGUI () (at Assets/Services/Analytics/Tracker/Editor/AnalyticsEventTrackerEditor.cs:40)
    UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor[] editors, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1253)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
     
    krou and Nidhii like this.
  2. Benvictus

    Benvictus

    Joined:
    Sep 12, 2013
    Posts:
    87
    @ferretnt

    I'm not sure on how you've set this up in your project.

    Could you please provide me with a small project that reproduces this issue?

    I will test this on my end and look at reporting this as a bug.
     
  3. ferretnt

    ferretnt

    Joined:
    Apr 10, 2012
    Posts:
    412
    Thanks. I'm very surprised nobody has hit this before as so far as I can see it isn't possible to change (or rename) any attribute which an AnalyticsTracker uses as a parameter without hitting the issue.

    Bug with teeny-tiny repro project (a scene with one script and two components) submitted. Fogbugz 1064881.

    Alex
     
  4. ferretnt

    ferretnt

    Joined:
    Apr 10, 2012
    Posts:
    412
    @Benvictus. Not sure if you were watching thread for replies but I figured I’d tag you in case.
     
  5. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,519
    @ferretnt

    Thanks for reporting this. I will assign the ticket to the correct team and they will take a look at how we can handle this case a bit more gracefully.
     
  6. krou

    krou

    Joined:
    May 29, 2014
    Posts:
    22
    The same error in Unity 2019.1.10f1. When trying to get property as dynamic parameter

    NullReferenceException: Object reference not set to an instance of an object
    UnityEngine.Analytics.TrackableField.GetValue () (at /home/builduser/buildslave/com.unity.analytics/package/Source/Unity.Analytics.Tracker/TrackableProperty/TrackableField.cs:48)
    UnityEngine.Analytics.ValueProperty.IsValid () (at /home/builduser/buildslave/com.unity.analytics/package/Source/Unity.Analytics.Tracker/TrackableProperty/ValueProperty.cs:93)
    UnityEditor.Analytics.StandardEventPayloadDrawer.ParametersGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, System.Boolean draw) (at /home/builduser/buildslave/com.unity.analytics/package/Source/Unity.Analytics.Editor/StandardEventPayloadDrawer.cs:322)
    UnityEditor.Analytics.StandardEventPayloadDrawer.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean draw) (at /home/builduser/buildslave/com.unity.analytics/package/Source/Unity.Analytics.Editor/StandardEventPayloadDrawer.cs:73)
    UnityEditor.Analytics.StandardEventPayloadDrawer.GetPropertyHeight (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at /home/builduser/buildslave/com.unity.analytics/package/Source/Unity.Analytics.Editor/StandardEventPayloadDrawer.cs:423)
    UnityEditor.PropertyDrawer.GetPropertyHeightSafe (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at C:/buildslave/unity/build/Editor/Mono/ScriptAttributeGUI/PropertyDrawer.cs:43)
    UnityEditor.PropertyHandler.GetHeight (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren) (at C:/buildslave/unity/build/Editor/Mono/ScriptAttributeGUI/PropertyHandler.cs:221)
    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:206)
    UnityEditor.EditorGUILayout.PropertyField (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren, UnityEngine.GUILayoutOption[] options) (at C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:9338)
    UnityEditor.EditorGUILayout.PropertyField (UnityEditor.SerializedProperty property, UnityEngine.GUILayoutOption[] options) (at C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:9322)
    UnityEditor.Analytics.AnalyticsEventTrackerEditor.PayloadGUI () (at /home/builduser/buildslave/com.unity.analytics/package/Source/Unity.Analytics.Editor/AnalyticsEventTrackerEditor.cs:60)
    UnityEditor.Analytics.AnalyticsEventTrackerEditor.OnInspectorGUI () (at /home/builduser/buildslave/com.unity.analytics/package/Source/Unity.Analytics.Editor/AnalyticsEventTrackerEditor.cs:37)
    UnityEditor.UIElements.InspectorElement+<CreateIMGUIInspectorFromEditor>c__AnonStorey1.<>m__0 () (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorElement.cs:462)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
     
  7. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please provide more information, an error message alone is generally not enough to troubleshoot.
     
  8. Max-T

    Max-T

    Joined:
    Apr 28, 2015
    Posts:
    1
    The same error I have in Unity 2017.3.1f1. When trying to get property as dynamic parameter.
    I solved this problem like this.
    The example code:
    public int mSomeValue = 0;
    public int SomeParameterCount
    {
    get
    {
    return mSomeValue;
    }
    set
    {
    mSomeValue = value;
    }
    }
    If I add SomeParameterCount to Analytics Event Tracker script as parameter for event, appear this error. So I just use mSomeValue to avoid this problem.
     
  9. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    You should no longer be using the Event Tracker Component, this functionality is built into the Editor now. More specifically, the Analytics Package in Package Manager.
     
  10. ferretnt

    ferretnt

    Joined:
    Apr 10, 2012
    Posts:
    412
    We abandoned Standard Events when the source code was replaced by an opaque binary library.