Any way to rotate a control 90 degrees?

Godot Version

v4.4.stable.official [4c311cbee]

Question

I’d like to rotate a label or button 90 degrees so that the text is moving in a downward direction. When I try to modify the rotation property in the Layout/Transform section of the inspector, it is greyed out and cannot be changed.

I’ve done some searching and the posts I’ve found seem to suggest this is possible, but they’re also all from before 2022, so perhaps this is something that was not carried over from Godot 3.

I might have to design my own control, but before I do that, is there any way to display labels, buttons or containers rotated by 90 degrees?

If your control node is a child of a Container type it’s transform, including rotation, will be managed by the container. Make your node not a child of a container type to rotate it freely, or rotate the parent container.

Well, I do want it to be managed by a parent container. I just want that container to manage a rotated version of it.

rotate the container.

I don’t know what your scene looks like, so it depends on a lot of things.

How do you rotate the container? Do you need a specific container? VBoxContainer and MarginContainer both have their transforms inaccessible.

I came up with this. It seems to work, but it calls some methods that are not exposed, so I’m not 100% sure it’s stable.

@tool
extends Container
class_name RotationContainer

func _get_minimum_size() -> Vector2:
	var children_size:Vector2
	for child in get_children():
		var min_size:Vector2 = child.get_minimum_size()
		
		if child.visible:
			children_size.x = max(children_size.x, min_size.x)
			children_size.y = max(children_size.y, min_size.y)
	
	return Vector2(children_size.y, children_size.x)

func _notification(what: int) -> void:
	if what == NOTIFICATION_SORT_CHILDREN:
		var s:Vector2 = size
		
		for child in get_children():
			child.rotation = PI / 2
			child.position = Vector2(s.x, 0)
			child.size = Vector2(s.y, s.x)

	if what == NOTIFICATION_THEME_CHANGED:
		update_minimum_size()