Cannot read properties of null (reading 'visible')

Needle : 3.45.2
Unity : 2022.3.12f1

Hi guys,
I have started occasionally getting the error shown in the screenshots and in the title. It happens as my game is loading. It causes my game to not properly load (In the screenshot you can see the entire view is weirdly skewed, and there is also no camera control and nothing progresses)

I have had the same scene setup for a long time now and this has only started happening recently. By default, I have a scene that has a particular gameobject disabled. I have a reference to it assigned via the inspector, and I enable it at a later time when its needed. However I do check the status of the gameObjects parent quite soon after the scene loads to see if it is disabled. I do it like this:

if (!GameObject.isActiveSelf(this.penaltyTaker?.gameObject.parent!)) {
      //The parent will be disabled in Pre Game, and only needs to be enabled once
      GameObject.setActive(this.penaltyTaker?.gameObject.parent!, true);
    }

Is it possible that doing a check on an object that is disabled very early on as the scene loads could occasionally cause the issue? This call is triggered by receiving a message across a web socket which can happen very soon after the application is launched. It is there as a safety check to ensure it is disabled by default in our builds. That has been my setup for many weeks now, but its only lately this issue has started. I dont directly query a “visible” status on anything.

Im not actually 100% sure the above is what is causing the issue. That is the only thing I can think of in any way related to something being “visible” as per the error. While awaiting a response to this thread, I will look at potentially reworking it so only the mesh is disabled as opposed to the entire object, though I suspect I may run into the same type of issue.

As a side note, on a previous project I used to check something like this
this.freeCamera!.gameObject.activeSelf= false;

and then it stopped working, and I had to change to:
GameObject.setActive(this.mainCamera!.gameObject, false);

Do changes like this only happen on upgrade to later versions, or do you push changes to existing, older versions of Needle?

Hi,

could you please open topics in :cactus: Needle Engine ? :slight_smile:

setActive does internally just set visible to false or true. The error suggests that the object in the three.js renderlist is undefined / null but it’s hard to say exactly without seeing the code and what exactly fails. Can you click on the chunk link and show come context? For debugging I could recommend you to create a breakpoint at that line in Chrome, then right click the breakpoint and enter a condition to only break if the object that will be checked there (“someObject.visible”) is null or undefined. Then you will see exactly what is causing this.

image

image

this is just an example - it will look different in your code

image


In general I can assure you that the package code doesn’t automagically change unless you update to a later version (existing versions never change)