onDisable is called even if onEnable was not?

Hey guys,

Just stumbled upon this:

Uncaught (in promise) TypeError: Cannot set properties of undefined (setting 'length')
    at OrbitControls2.onDisable (chunk-K4LBNQTN.js?v=29c165a8:46369:38)
    at chunk-K4LBNQTN.js?v=29c165a8:26172:18
    at perComponent (chunk-K4LBNQTN.js?v=29c165a8:26213:7)
    at updateIsActiveInHierarchyRecursiveRuntime (chunk-K4LBNQTN.js?v=29c165a8:26161:7)
    at updateIsActive (chunk-K4LBNQTN.js?v=29c165a8:26126:25)
    at GameObject.setActive (chunk-K4LBNQTN.js?v=29c165a8:39149:5)
    at MyClass.awake (MyClass.ts:23:18)
    at MyClass.__internalAwake (chunk-K4LBNQTN.js?v=29c165a8:39748:10)
    at safeInvoke (chunk-K4LBNQTN.js?v=29c165a8:25893:7)

Both objects are part of the same prefab/AssetReference. MyClass is deactivating the OrbitControls object during awake. Edit: Both components actually sit on the same object.

Anyway, I think onDisable should only be called when onEnable was called before.

1 Like

I’m sorry, I couldn’t find a response but notified the team :cactus:

1 Like

Hi, I agree I think if onDisable is called in this case it’s a bug. Trying to repro on Stackblitz but so car i cant reproduce it: Needle-engine - Vite Template (duplicated) - StackBlitz

Can you share a screenshot of your hierarchy? Pehaps also modidy the code in my link so the error happens?

Please try and put the object with both components into an asset you load via AssetReference. Should repro then I think.