简体   繁体   English

在手机屏幕边框内嵌绘制【附示例图】

[英]Draw inline at mobile screen border [With example pictures]

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?是否可以在屏幕的边框上画一条线,比如一个“内联”,宽度一致,比如 10 个像素,这样它就可以与屏幕的边缘对齐,即使是在圆角处?

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?) (否则任何其他解决方案都可以吗?Android studio 可能吗?)


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我想要实现的是在每个屏幕上始终与屏幕边框形状相同的线条,无论角的半径如何

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.我认为这在正常情况下是不可能的,因为 Unity 将屏幕视为一个矩形,因此它不会为您提供有关屏幕角形状的任何信息。

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.您可以使用SystemInfo.deviceModel获取设备的 model,然后您可以从服务器或类似的东西检索其屏幕形状的信息。

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 :如果其为 0,则表示屏幕为矩形,否则屏幕以给定的半径r 圆角

在此处输入图像描述

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.有了这些信息,您可以将其传递给后处理着色器,该着色器将评估从每个像素到屏幕角落的最小距离,如果该距离小于您定义的某个值,您可以用不同的方式绘制它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM