[Unity 3d] 异形屏UI布局解决方案 - NotchSolution

解决缺口/切口屏幕手机UI布局问题的一组组件和工具

GitHub 上的工程多如繁星,有些好的仓库,但凡不经意间错过了就很难找回,故稍作采撷,希望能帮助到有心人。

简介:

A set of components and tools to solve notched/cutout phones layout problems for Unity. Whether you like it or not, the time has come for us designers to design in context of a notch and embrace it instead of hiding it. This tool also enables design-time preview which help you iterate your design without building the game. Minimum Unity version 2019.1.
- 一套用来解决 Unity 中缺口/切口手机UI布局问题的组件和工具。 不管你喜欢还是不喜欢,带缺口的全面屏就在那里,于是我为它设计了这个适配工具。 该工具还允许设计时预览,都不需要打包调试吼。

功能:

Components : Attach to your game objects to make them notch-aware.
组件式 - 挂载插件提供的组件即可实现异形屏的缺口规避

  1. SafeAreaPadding: RectTransform layout component for uGUI based on the value returned by Screen.safeArea.
    - 基于 Screen.safeArea 返回值的UGUI RectTransform 布局组件
  2. Adaptation Components: Adapts any game object with Animation Playables API and Animator component.
    - 适配任意的挂载 / 使用了Animation Playables API 和 Animator 组件的游戏对象
    • AspectRatioAdaptation: Dynamically changes anything based on the ratio of the screen.
      - 根据屏幕的比例动态更改任何内容
    • SafeAreaAdaptation: Dynamically changes anything based on the safe area.
      - 根据安全区域(safe area)动态更改任何内容

Simulation : Iterate your design in context of notch right from Unity editor.
可仿真 - 让你无需真的打包安装到手机就能以所见即所得的仿真方式调试与设计与迭代

测试仿真效果,注意看左右翻页按钮在勾选仿真后向中心靠拢了

  • 目前支持模拟仿真的设备如下:
    • iPhone X

    • iPad Pro
      (Contributed by 06Games)

    • Huawei Mate 20 Pro

    • OnePlus 6T

    • Samsung Galaxy S10

    • Samsung Galaxy S10+

使用:

  1. 只需在工程 Package/ manifest.json 插入一行 "com.e7.notch-solution": "git://github.com/5argon/NotchSolution.git"就能通过 Unity PackageManager 安装。当然直接直接下载使用啦。
  2. Android 需勾选位于 Resolution and Presentation 下的 “Render outside safe area” 。


演示:

链接:

5argon/NotchSolution
su10/AutoScreen: A smart solution of safe area for Unity. - 类似仓库

结语:

  • Unity 2019.2 开始本文前面提到的 safe area 还能返回 一个环绕缺口的矩形面积,这个仓库正在研究使用这个特性,敬请关注。

  • 转载请注明出处,谢谢~

本文集持续更新ing,喜欢记得点赞关注哦!

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容