unity android_Unity中的Android主题

unity android

For an introduction into Android themes and styles, feel free to refer to Google documentation: http://developer.android.com/guide/topics/ui/themes.html

有关Android主题和样式的介绍,请随时参考Google文档: http : //developer.android.com/guide/topics/ui/themes.html

If you are designing a game, where the world and the UI are rendered full-screen by Unity, why care about the themes?

如果您要设计游戏,而Unity则以全屏方式呈现世界和UI,那么为什么要关心主题?

First of all, you may want to display a WebView, or another sort of dialog with standard Android interface, and it will by default inherit the applications theme.

首先,您可能想要显示一个WebView或其他具有标准Android界面的对话框,并且默认情况下它将继承应用程序主题。

Second, when clicking an InputField or calling TouchScreenKeyboard.Open(), you have the keyboard displayed along with the input box. Themes are applied to this input box.

其次,当单击InputField或调用TouchScreenKeyboard.Open()时,将显示键盘和输入框。 主题将应用于此输入框。

At the moment of writing this post, Google has three main theme families:

在撰写本文时,Google具有三个主要主题系列:

    Let’s check it out:

    让我们来看看:

    Holo

    霍洛

    image00

    Material

    材料

    image01

    NoTitleBar

    NoTitleBar

    image02

    Third point of applying the themes – if you want to get your game or app featured by Google, you have to apply the latest theme available at the moment (now this is Material).

    应用主题的第三点–如果您想让您的游戏或应用被Google精选,则必须应用当前可用的最新主题(现在是Material)。

    However, there is another way to deal with the themes – appcompat library, which is a part of the Android Support Library package. Google publishes this library for the developers to be able to apply recent themes to older devices, for example, Material to pre-Lollipop devices. This is a good way to go with regular Android apps, however we at Unity do not include appcompat into our standard package for a number of reasons (apk size being the most important). You can add appcompat to a Unity game yourself if you’d like to – either as a plugin or in Android Studio after exporting the project.

    但是,还有另一种处理主题的方法– appcompat库,它是Android支持库程序包的一部分 。 Google发布了该库,供开发人员使用,以将最新主题应用于较旧的设备,例如,将Material应用于预棒棒糖设备 。 这是与常规Android应用程序搭配使用的好方法,但是出于多种原因(apk大小是最重要的),我们Unity并未将appcompat包含到我们的标准软件包中。 如果需要,您可以自己将appcompat添加到Unity游戏中-作为插件或在导出项目后在Android Studio中添加。

    Now back to Unity. If you take a look at our default manifest, you will see the following:

    现在回到Unity。 如果您查看我们的默认清单,将会看到以下内容:

    1

    1

    By default, we are applying the theme that is available on all supported devices (Android 2.3 Gingerbread and later). Good news is that we now allow you to override this setting in your own manifest (more details on overriding the manifest are here, long story short – place your manifest into Assets/Plugins/Android/AndroidManifest.xml, but beware as it overrides our manifest completely). Setting your own theme works starting from version:

    默认情况下,我们将应用所有支持的设备(Android 2.3 Gingerbread及更高版本)上可用的主题。 好消息是,我们现在允许您在自己的清单中覆盖此设置(长话短说,有关覆盖清单的更多详细信息在这里 ,将您的清单放入Assets / Plugins / Android / AndroidManifest.xml中,但请注意,因为它会覆盖我们的清单完全体现)。 从版本开始设置自己的主题即可:

          However please don’t rush overriding the manifest to change the theme! We have one more thing for you ☺ At runtime, on initialization, Unity Android player checks whether you changed the default Unity theme (Theme.NoTitleBar.Fullscreen):

          但是,请不要急于覆盖清单来更改主题! 我们还有另一件事给您☺在运行时,初始化时,Unity Android播放器会检查您是否更改了默认的Unity主题(Theme.NoTitleBar.Fullscreen):

              So the bottom line is – if you don’t override the default Unity theme in Android manifest, we will apply the latest available theme for the device running the game, at runtime. Please be careful when overriding the manifest completely. If you don’t specify any theme at all for your application, Android will choose Theme.DeviceDefault, which may result in different and possibly disappointing results on different devices. You may want to keep the Unity’s default

              因此,最重要的是–如果您不覆盖Android清单中的默认Unity主题,我们将在运行时为运行游戏的设备应用最新的可用主题。 完全覆盖清单时,请小心。 如果您根本没有为应用程序指定任何主题,则Android将选择Theme.DeviceDefault,这可能导致在不同设备上产生不同的结果,并且可能令人失望。 您可能要保留Unity的默认设置

              1

              1

              in your custom manifest, and we will take care of dynamically applying the best theme for you.

              在您的自定义清单中,我们将为您动态地应用最佳主题。

              翻译自: https://blogs.unity3d.com/2015/07/16/android-themes-in-unity/

              unity android

              • 0
                点赞
              • 1
                收藏
                觉得还不错? 一键收藏
              • 0
                评论
              评论
              添加红包

              请填写红包祝福语或标题

              红包个数最小为10个

              红包金额最低5元

              当前余额3.43前往充值 >
              需支付:10.00
              成就一亿技术人!
              领取后你会自动成为博主和红包主的粉丝 规则
              hope_wisdom
              发出的红包
              实付
              使用余额支付
              点击重新获取
              扫码支付
              钱包余额 0

              抵扣说明:

              1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
              2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

              余额充值