Is this a bug in Godot or an issue with my mistake?

Godot 4.2.2

Question

Open a scene that is not the main scene in the editor and press F5 to run the project. The UI size of the main scene will change. But when the main scene is opened in the editor, pressing F5 will run the project, and the UI size of the main scene will be displayed correctly

Please show images to help us understand. It would better to show us the tree and problem than ask us to recreate the error with no knowledge of what scripts are happening, and the tree.

The UI of nodes a and b will change in size when the editor opens a scene that is not the main scene.

This is the editor running the project in the main scene, with the UI displaying correctly.

This is the editor running the project in a non main scenario, and the UI size will change.

This happens because the base for your UI (the sence_BG) cannot ‘expand’ accordingly to the parent(as it is a Node2D and not a Control Node)
You can fix this by

  1. changing the main node to control (and making it expand)
  2. adding script to change the position of UI accordingly
    Personally I prefer method 2. as it allows me to use it in other nodes as well.

Thank you. After some research, I found that the problem should be caused by AnimationPlayer(UI_roll) nodes.After I deleted AnimaitionPlayer(UI_roll), the problem disappeared.

That sounds like it might be related to: