Draw inline at mobile screen border [With example pictures]

Viewed 29

Is it possible to draw a line at the border of the screen, like an "inline" with a consistent width of lets say 10 pixels, so that it aligns to the edges of the screen, even at the rounded corners?

Like this:


normal screen


with the wanted inline (Orange line)


Is there a unity solution? (Otherwise any other solution would be good to! Android studio maybe?)


What I want to achieve is a line that's always the same shape as the screen borders, on every screen, no matter the radius of the corners

1 Answers

I don't think this is possible in normal ways, since Unity considers the screen as a rectangle, so it will give you no information about the shape of the corners of your screen.

However, it is not impossible. You can use SystemInfo.deviceModel to get the model of a device and then you can retrieve information of its screen shape from a server or something like that.

The only necessary information the server needs to store is the radius of the corner. If its 0, means the screen is a rectangle, otherwise the screen is rounded with the given radius r:

enter image description here

Having this information, you can pass it to a post processing shader that will evaluate the minimum distance from each pixel to the corner of the screen, and if this distance is less than some value you defined, you can paint it differently.

Related