When the `UICanvas.renderMode` is `CanvasRenderMode.ScreenSpaceCamera`, if the `camera.entity` is the same as the `canvas.entity` or a child of the `canvas.entity`, it will fall into an infinite loop.
Describe the bug A clear and concise description of what the bug is.
To Reproduce Steps to reproduce the behavior:
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
Smartphone (please complete the following information):
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
Additional context Add any other context about the problem here.
当画布的渲染模式为 ScreenSpaceCamera ,但相机节点为画布的子节点时:
相机节点的世界坐标改变 ----> 影响画布节点的世界坐标
画布节点的世界坐标改变 ----> 影响相机节点的世界坐标
相机节点的世界坐标改变 ----> 影响画布节点的世界坐标
画布节点的世界坐标改变 ----> 影响相机节点的世界坐标
相机节点的世界坐标改变 ----> 影响画布节点的世界坐标
画布节点的世界坐标改变 ----> 影响相机节点的世界坐标
…死循环…
看了一下 Unity 在这部分做的处理,首先在正常情况下(相机节点不是画布的子节点):
然后将相机节点拖到画布中:
可以发现,当相机节点为画布子节点时,画布不随着相机位置改变而改变。这样也有点突兀(至少在文档中描述起来比较难理解)。
我理解现在这种模式下,当相机不是画布的子节点,调整相机的坐标啥的,你是动态调画布节点的 Transform 来适配相机,当相机是子节点的时候,死循环了对么?
我理解现在这种模式下,当相机不是画布的子节点,调整相机的坐标啥的,你是动态调画布节点的 Transform 来适配相机,当相机是子节点的时候,死循环了对么?
是的,如果是相机模式下,需要遵循: 「画布和相机的相对位置不变」 那么相机的世界坐标改变的时候,画布的世界坐标也应该改变,本来这个改变应该是由相机主导,画布跟随的,但是如果相机是画布的子节点,那么在画布跟随改变后,又转头影响相机的世界位置,然后就死循环。