Godot Version
4
Question
The problem is in some phones it works correctly (reddmi note 11 pro plus 5g) and two other but in two phones it did not work (a22) Log on the right is wrong and should be placed on the left side of screen I used canvaslayer-control-… For it and used the anchors On the other hand the move buttons that i made and gave them a sciript( seccond pic codes) Works fine what am i doing wrong?
link to pictures
extends CanvasLayer
@onready var ui: CanvasLayer = $"."
@onready var left_button: TouchScreenButton = $left_button
@onready var right_button: TouchScreenButton = $right_button
@onready var up_button: TouchScreenButton = $up_button
@onready var dash_button: TouchScreenButton = $dash_button
var error_margin_left = 100
var horizental_space = 350
func _ready() -> void:
var os_name = OS.get_name()
if os_name == "Windows" or os_name == "web" or os_name == "linux":
ui.visible = false
#if os_name == "Android":
var frame_size = get_viewport().get_visible_rect().size.x
var frame_size_5 = frame_size * 0.8
var frame_size_1 = frame_size * 0.12
var safe_area = DisplayServer.get_display_safe_area()
var safe_area_left = safe_area.position.x
left_button.position.x = frame_size_1 - error_margin_left
right_button.position.x = left_button.position.x + horizental_space
up_button.position.x = frame_size_5 - 65
dash_button.position.x = frame_size_5 + 100
print("Os ", str(os_name))
print("safe area ", str(safe_area_left))
print("screen_size ", str(frame_size))