I need to specify Actual pixel size in a scaled UI

I have a 2D game (somehow app) with fractional canvas_item scale mode (with keep_width aspect ratio). my base resolution is 360* 640. so in my phone (1080*2400) every pixel size is 3x. but I need to draw a narrow line in UI. I like it to be 1px in every resolution. how I can do it?

You have to mix resolutions. Set the resolution to the screen resolution. Then the game scene needs to be in its own viewport at the lower resolution and stretched to be 3x again. Then the ui you are after can be rendered with the 1 pixel resolution you desire.

so you say that there is no way to draw a precise pixel control in a scaled viewport? seems rational! but my desired goal is to draw a pixel-perfect object in a deep hierarchy and I can’t add another unscaled viewport and mix them easily! so maybe it would be better to give up.
but there is one thing that may solve my problem. how i can obtain the viewport scale ratio? should I calculate it based on resolution or is there a property or easier way?

there are no easy ways that i can see, so you will have to calculate it by hand.