Player log is spammed with errors when overriding default credits

Following this post Cesium Credits · Issue #333 · CesiumGS/cesium-unity · GitHub I was able to customize the credits (repositioned on screen).

In builds, everything works as expected, but the player log appears to log an error every frame related to the credits:

NullReferenceException: Object reference not set to an instance of an object.
at CesiumForUnity.CesiumCreditSystemUI.SetCreditsOnVisualElements (UnityEngine.UIElements.VisualElement onScreenElement, System.Collections.Generic.List1[T] onScreenCredits, UnityEngine.UIElements.VisualElement popupElement, System.Collections.Generic.List1[T] popupCredits, System.Boolean removeExtraSpace) [0x00000] in <00000000000000000000000000000000>:0
at CesiumForUnity.CesiumCreditSystemUI.SetCredits (System.Collections.Generic.List1[T] onScreenCredits, System.Collections.Generic.List1[T] popupCredits) [0x00000] in <00000000000000000000000000000000>:0
at CesiumForUnity.CesiumCreditSystem.UpdateCredits (System.Boolean forceUpdate) [0x00000] in <00000000000000000000000000000000>:0

To be clear, these errors don’t appear in the editor.

Since this is all happening within CesiumForUnity scripts, I’m not sure how effectively I’ll be able to diagnose the issue or suppress these errors.

If there’s a way for me to provide more helpful information, please let me know.

Hi @ShawkiVA,

It would help to receive more details so we can properly troubleshoot this error. Can you take a screenshot of your credit system setup? Specifically, views of the credit system + UI components on the game object.

Can you also describe the changes you made to customize the credits in more detail? For example, what were the changes you made in script? What were the changes you made to the UI asset itself?

Thanks @janine,

This is the set up of my CesiumCreditSystemDefault (as mentioned within the github post). The CesiumCreditSystemDocument component effectively just displays a UIDocument on a RawImage. The RawImage is on a separate GameObject that is a child of this one (and contains nothing else).

I’d have to dig into this, but I believe the actual UI of the credits hasn’t changed. The VergeCesiumCreditSystemUI in the screenshot appears to be identical to the CesiumCreditSystemUI asset. The 3D Tiles are displayed on their own RawImage. The purpose of this change was to move the credits to the bottom left corner of that RawImage rather than the bottom left corner of the entire screen (and in the way of other elements), as it felt more appropriate there.

Effectively, very little was actually changed about the credits, other than overriding them so that I could position them somewhere else.

Hello, I think the problem maybe you set UI Document as inactive (in your screenshot above).

When I disable it, I get the same Null Reference Exception and it only happens in a packaged build.

Hope this helps

That seems to have taken care of it. I actually am setting the UIDocument active in Awake(), so I must’ve been getting all of those errors prior to that.

Thank you!