Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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. #2560

Open
cptbtptpbcptdtptp opened this issue Feb 14, 2025 · 4 comments
Assignees
Labels
2D bug Something isn't working GUI

Comments

@cptbtptpbcptdtptp
Copy link
Collaborator

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. 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.

@cptbtptpbcptdtptp cptbtptpbcptdtptp added 2D bug Something isn't working GUI labels Feb 14, 2025
@cptbtptpbcptdtptp cptbtptpbcptdtptp self-assigned this Feb 14, 2025
@cptbtptpbcptdtptp
Copy link
Collaborator Author

当画布的渲染模式为 ScreenSpaceCamera ,但相机节点为画布的子节点时:
相机节点的世界坐标改变 ----> 影响画布节点的世界坐标
画布节点的世界坐标改变 ----> 影响相机节点的世界坐标
相机节点的世界坐标改变 ----> 影响画布节点的世界坐标
画布节点的世界坐标改变 ----> 影响相机节点的世界坐标
相机节点的世界坐标改变 ----> 影响画布节点的世界坐标
画布节点的世界坐标改变 ----> 影响相机节点的世界坐标
…死循环…

@cptbtptpbcptdtptp
Copy link
Collaborator Author

看了一下 Unity 在这部分做的处理,首先在正常情况下(相机节点不是画布的子节点):

Image

然后将相机节点拖到画布中:

Image

可以发现,当相机节点为画布子节点时,画布不随着相机位置改变而改变。这样也有点突兀(至少在文档中描述起来比较难理解)。

@singlecoder
Copy link
Member

我理解现在这种模式下,当相机不是画布的子节点,调整相机的坐标啥的,你是动态调画布节点的 Transform 来适配相机,当相机是子节点的时候,死循环了对么?

@cptbtptpbcptdtptp
Copy link
Collaborator Author

我理解现在这种模式下,当相机不是画布的子节点,调整相机的坐标啥的,你是动态调画布节点的 Transform 来适配相机,当相机是子节点的时候,死循环了对么?

是的,如果是相机模式下,需要遵循:
「画布和相机的相对位置不变」
那么相机的世界坐标改变的时候,画布的世界坐标也应该改变,本来这个改变应该是由相机主导,画布跟随的,但是如果相机是画布的子节点,那么在画布跟随改变后,又转头影响相机的世界位置,然后就死循环。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2D bug Something isn't working GUI
Projects
None yet
Development

No branches or pull requests

2 participants