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

2D label ignores rotation at runtime #37577

Closed
ghost opened this issue Apr 4, 2020 · 6 comments
Closed

2D label ignores rotation at runtime #37577

ghost opened this issue Apr 4, 2020 · 6 comments

Comments

@ghost
Copy link

ghost commented Apr 4, 2020

Godot version:
3.2.1.rc2.offical
OS/device including version:
Windows 10
Issue description:
I try to create a UI with rotated labels in by using editor functionallity.
Steps to reproduce:

  • create a simple scene
  • add a HBoxContainer
  • add a Label to the container
  • set rect rotation to 270

The editor shows the correct rotation, but is reseted on runtime

Minimal reproduction project:
https://drive.google.com/drive/folders/118XNo2g2K6kXGNAq0xQijb9wWr-K9WJX?usp=sharing

@ghost ghost changed the title 2D Labe ignores rotation at runtime 2D label ignores rotation at runtime Apr 4, 2020
@Anutrix
Copy link
Contributor

Anutrix commented Apr 4, 2020

You are not supposed to set transforms like the rotation of children of Containers. The containers themselves do set it. You get a warning telling that too.

@ghost
Copy link
Author

ghost commented Apr 4, 2020

I try different ways and nothing is working.
When i added a label direct under the root control and set the rotation than it works as expected
When i added the label under other controls e.g. GridContainer it fails and is reset when reload the project.
Also use "extra" Container for a label (by the way makes no sence to have a extra layer only for a label) and set the rotation on the Container not works. Is also reset on project loading.

I attach my example project maybe this will better show the problem

@Zireael07
Copy link
Contributor

It is not working because all Containers control rotations, as @Anutrix told you.

@ghost
Copy link
Author

ghost commented Apr 4, 2020

Can you provide me an working example please?
I applied the rotation to the parent Container of the label and it not works, it works temporary during editng. But when save and reopen the project the rotation value is lose

@aaronfranke
Copy link
Member

Children of containers have their position and rotation exclusively determined by their parent.

The minimal reproduction project you posted doesn't actually show the bug because this isn't an issue of things being different on runtime, this is about things being invalid - if you restart Godot, you will see that everything moves to be the way it's supposed to be.

This is well documented and Godot already has a big yellow warning and also prevents you from visually editing children of containers to prevent you from getting into this invalid state.

Currently Godot doesn't prevent you from editing the values in the inspector, but this part is already being tracked by #28718 which will be fixed by #30623 in 4.0.

@Erfa
Copy link

Erfa commented Mar 5, 2022

So if rotation is also controller by the parent, how do you rotate something? There's no RotationContainer, right? Do you need to write a custom container for this to work?

EDIT: Actually this appears to work and was simpler than I expected. Something like this should work if anyone else is having this issue, just attach this script to a container, and the children will be rotated.

extends Container

export var rotation := 0.0 setget set_rotation, get_rotation

func _notification(what):
	if what == NOTIFICATION_SORT_CHILDREN:
		for child in get_children():
			child.rect_rotation = rotation

func set_rotation(r: float):
	rotation = r
	queue_sort()

func get_rotation() -> float:
	return rotation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants