#Cannot set properties of undefined (setting 'activeSelf')

1 messages · Page 1 of 1 (latest)

junior tartan
#

Hey,
We have a project we have been working on for months. We recently moved it from a monorepo to a standalone repo, and are now getting an error related to calling "activeSelf" on a gameObject (a script that hasnt been changed in months).

In multiple places where I have references to setting gameObject.activeSelf to true or false, I have had to change them to use GameObject.setActive instread.

For example, this.freeCamera!.gameObject.activeSelf = false; to GameObject.setActive(this.freeCamera!.gameObject, false);

Screenshot 1 - Shows the error
Screenshot 2 - Shows changing the old commented out way to the new way that works but I need to be able to check against activeSelf in other areas so this isnt a solution to move forward.

Is there any reason why this would just suddenly stop working without any change in Needle version? This works in our old monorepo version without any issue. The codebase is identical in both.

Needle : 3.40.0
Unity : 2022.3.12f1

cold brambleBOT
# junior tartan Hey, We have a project we have been working on for months. We recently moved it ...

Thanks for reaching out @junior tartan

Please read through the following and share the information requested. This will help us to better assist you.

Description

Describe the issue that you're seeing. Please be as detailed as possible e.g. is this issue happening in Unity or Blender, which Needle Engine version are you using, do you see any errors in the Editor or Browser console, etc.

Information:

  • If you're using Unity click the menu item Needle Engine/Report a Bug/Copy Project Info to Clipboard. Please share the results below.
  • Please provide code snippets using Discord Code Blocks
  • Have you contacted Needle through another channel or just through Discord?

Useful Links

Did you know 💡

We now also have a forum with AI support: Join now with your discord account - or request help by clicking the button below.

silent bramble
#

Hi, the error says gameObject is undefined which would suggest that this.freeCamera / this.mainCamera might not be what you expect? Your code supressed a possible null reference - are you sure this.freeCamera is not null or undefined?

junior tartan
#

Its not null or undefined no. freeCam is assigned in the inspector, and has been for months. Same with all the other instances where the null possiblity is suppressed. They're suppresed as theyve been assigned for months in the inspector.

#

Thanks for the reply btw. If it was a null issue, wouldnt the GameObject.setActive also give the error?