With this approach the issue of gameObject being displaced on resize is fixed.
But the debugDraw gets completely offset when resized. I have attached screenshots for reference.
You need to modify the orthoheight of the camera on the root node.
When the canvas size changes, it will automatically adapt to the camera configuration on the canvas and will not modify the root-node’s camera.
Unfortunately this doesn’t solve the issue if using just fitWidth or fitHeight alone. If both are enabled it works well.
There seems to be some issue with changing the layer property of the Debug Draw node.
It is set to Layer.Enum.UI_2D when it is being created in physics-world.ts
I generally tend to modify fitWidth & fitHeight as per the aspect ratio during runtime.
The solution you provided me works well when both fitWidth & fitHeight is set to true.
Can you please uncheck the fitHeight or fitWidth and try again.
Here’s the build where I’m trying to change the layer property of the DebugDraw node. physicsDebug.zip (2.1 MB)
Please Note: The canvas layer is set as test in the build. Hence the Debug Data may not be rendered.
Thanks a lot Koei. This works as expected. I was under the impression that the layer settings couldn’t be overridden for debugDraw. I had no idea that I should update it a frame later for it to take effect.