Creator 版本: 3.7.4
目标平台:360浏览器
预制体实例化并设置父级后我想立刻取消激活以便之后再激活,以下两种方案第一种报错,第二种不方便。
方案一:先取消激活再设置父级,setParent()会自动调用enable,但是里面我写了一些内容不想这时候运行。所以先取消激活就不会运行了,但这样的话之后重新激活的时候就报错了。好像是说预制体上带的刚体的问题。
方案二:先设置父级再取消激活,enable会被自动调用然后再disable,不报错了,但是enable里面写的逻辑会执行,要想其它方式回避。
报错信息里面只有onbegincontact是我自己写的
2024-8-26 21:01:10 - error: [Browser Preview]Cannot read properties of null (reading ‘SetActive’)/nTypeError: Cannot read properties of null (reading ‘SetActive’)
at b2RigidBody2D.setActive (http://localhost:7456/scripting/engine/bin/.cache/dev/preview/bundled/index.js:287177:22)
at b2RigidBody2D.onEnable (http://localhost:7456/scripting/engine/bin/.cache/dev/preview/bundled/index.js:287007:16)
at RigidBody2D.onEnable (http://localhost:7456/scripting/engine/bin/.cache/dev/preview/bundled/index.js:313347:24)
at OneOffInvoker.invokeOnEnable [as _invoke] (http://localhost:7456/scripting/engine/bin/.cache/dev/preview/bundled/index.js:46965:18)
at OneOffInvoker.invoke (http://localhost:7456/scripting/engine/bin/.cache/dev/preview/bundled/index.js:46835:16)
at NodeActivator.activateNode (http://localhost:7456/scripting/engine/bin/.cache/dev/preview/bundled/index.js:48853:27)
at Node.set (http://localhost:7456/scripting/engine/bin/.cache/dev/preview/bundled/index.js:52606:52)
at Plane._onBeginContact (http://localhost:7456/scripting/x/chunks/85/852832fa392304c6ff1420fc5844f056f4e9b1d8.js:505:71)
at BoxCollider2D.emit (http://localhost:7456/scripting/engine/bin/.cache/dev/preview/bundled/index.js:159386:28)
at PhysicsContactListener.emit (http://localhost:7456/scripting/engine/bin/.cache/dev/preview/bundled/index.js:311762:77)
