Games in Unity
Unity Game on Android TV
27 min
an airconsole app for androidtv is available on the google play store unfortunately, the androidtv cannot run the webgl versions of unity games that we have in the airconsole store in order to run your unity made airconsole games on android tv, you need to create a native android build instead of the regular webgl build some adjustments may have to be made to your game project, as detailed in this guide when you switch platforms to android and export your game to an androidtv, the airconsole plugin creates a webview that shows airconsole content within your androidtv app following this guide will give you an apk file which can then be uploaded to the google play store if you are thinking about porting your airconsole game to androidtv, please contact us beforehand we have additional unity version specific information at the end of this guide make sure to read it to avoid problems with your build process tools you want to make sure your unity version is the latest unity lts version suitable for your game to be compatible with androidtv requirements 2022 3 2021 3 make sure your airconsole plugin version is 2 11 or higher install the unity sdk and ndk that can be installed as part of the android module in unity hub platform before you start working on your androidtv port, it's important that you have uploaded a zip of your webgl build to airconsole com/developers and create the game id which we will need for the next steps read the "publish your game" guide which explains how to upload your game in file → build settings , choose 'android' reimporting assets for the platform might take a moment bundleid go to edit → project settings → player in the other settings tab, you'll find the parameter bundle identifier for your androidtv build to work, this needs to be identical with the game id that you've given your game on airconsole com/developers n b it can also be called "package name" on some unity versions attention the bundle identifier can not include com airconsole configuring the android platform starting with unity lts 2021, unity no longer includes opengl es2 in builds with auto graphics api enabled in the android player settings you need to disable auto graphics api and manually add it back screen and controller data in order for your exported game to be able to access the controller and all necessary javascript and image files, you need to have a webgl build with all needed screen and controller data uploaded to airconsole com/developers copy the game upload version number of your game paste the number into the android tv game version field on the airconsole gameobject in your scene save your scene and create an android build the gamename apk file you get can be deployed to your androidtv device onready / ongameend users can return to the airconsole store by selecting 'change game' on their phone without leaving your android app because of that, you need to mute all sound in your game in the ongameend event, like you would in the onadshow event pause / stop as much of your game as you can to make sure no unnecessary computation is happening behind the web view after users have chosen to 'change game' similarly, only start playing your game's sound/music in the onready event, not on start / awake / scene loaded loading screen sprite you can choose a custom loading screen logo to be displayed when your game starts on android tv if there is none, a default airconsole logo will be displayed ui on androidtv, the airconsole default ui bar will be laid over the game the default ui shows the airconsole logo, the session code and connected players' portraits and connection statuses to make sure your ui is displayed correctly despite the cutoff at the top, the airconsole object offers three options on how to deal with canvases no resizing your ui is left as it is, but the default ui is laid over if you choose this option you can either manually adjust your ui so that nothing important will be cut off at the top resize camera the height of the default ui is subtracted from the maincamera's pixelrect on your canvas, set rendermode to screen space camera now, if your ui elements' recttransforms are correctly anchored, they will not be cut off by the default ui resizing the camera will change its aspect ratio resize camera and reference resolution the camera is resized as described in option 2) in addition, the reference resolution of your canvas scalers is adjusted to keep the aspect ratio it had before this will ensure that ui elements are placed correctly in relation to the 3d elements in your game scene it means, however, that your canvas is narrower than your camera execution order the resizing happens in the onlevelwasloaded event do not depend on the order of onlevelwasloaded being before or after the onenable/awake/start events nested canvases we recommend not using nested canvases (i e a canvas as child of another canvas) using nested canvases can lead to issues with some of the resizing options performance even if your game is already well optimized for web, you may run into performance issues on androidtv to test and improve performance, we recommend implementing an fps counter in your game and testing on the targeted hardware frequently testing if you do not own an android tv device for testing, we recommend testing on an android phone instead once you have a working build, send it to us and we will test it on our android tv devices this is especially useful for testing ui adjustments and camera resizing if your games performance is insufficient and the unity mobile optimisation tips were insufficient for android tv, we have the following additional advise use multiple quality levels for your game driven by systeminfo graphicsdevicetype a low quality for hardware that is used when the device only supports opengl es2 limit the maximum shader quality level / use low end mobile optimized approximations of the shaders, disable shadows, limit pixel lights to 1 and anti aliasing to none or msaax2, limited or no anisotropic texture filtering a higher quality level based on opengl es3 or vulkan that can use more pixel lights, some amount of shadows, msaax4 and aa filtered textures the hardware can support a maximum of 400 pure static batches / draw calls ensure that all textures are compressed to reduce load time and memory usage while improving performance optimally you would want etc1 or distinct assetbundle/addressable levels for low end android tv devices and the other platforms disable post processing and visual effects on your camera if you detect that you are on a low performance device reduce transparent geometry, avoid using big, transparent sprites or dense particle effects reducing the resolution of your game with screen setresolution() can be a solution to performance issues if you do resize your game, call setresolution in a start event, not in awake avoid using the unity scriptable renderpipeline (urp, lwrp) it is not optimized for opengl es2 creating significant performance problems make use of the unityengine profiling profilerrecorder with memory markers and rendering markers to identify runtime performance in release build \ if you need more detail, make development builds with the autoconnect profiler option enabled and see what has impact on performance we recommend trying out one of these optimizations at a time and see which have impact, if necessary release build once your game is ready for release, there are a few more things to consider debug build make sure the build you send is not a debug debug build make sure to uncheck the development build development build checkbox in your unity build settings key & key store you need to sign your apk for release to do so, you can create a new keystore in the player settings version versions are used to determine the version of the build this versions is very important on the android store listings and for our qa to review and activate the respective game please always increase the version if you create a new version for review bundle code the bundle code is an integer that is used to determine whether one version is more recent than another, with higher numbers indicating more recent versions you must increase the number by one every time you release a new version the same bundle code cannot be used twice note a bundle number may count as 'used' even when the build was not actually released publicly to be on the safe side, increase your bundle code every time you send us a new build during the release process android manifest the android manifest is an xml file that provides essential information about your app to the android system, which the system must have before it can run any of the app's code in the manifest, you also determine which devices your game supports the default airconsole android manifest that we include in our plugin assumes you want your game to appear only on android tv systems (which use the “leanback” android ui) and not on android tablets if you want your airconsole game to be playable on android tablets as well, simply remove the following lines from the android manifest \<uses feature android\ name="android software leanback" android\ required="true" /> \<category android\ name="android intent category leanback launcher" /> screen orientation on some devices, the screen orientation needs to be set explicitly make sure screen orientation is set to "landscape" in your android manifest android\ screenorientation="landscape" android\ screenorientation="landscape" more information here target api to support a wide range of devices, the minimum api level has to be set down to api level 22 api level 22 and the target api level to api level 33 api level 33 (at least) build for android 13 with unity to support android 13 (api level 34), the package visibility element was added to the airconsole unity plugin (v2 6 or later) unity version specific configuration gradle configurations instructions for supported versions of unity are listed in the following sections versions of unity that do not support customization of gradle are unable to target android 13 (api level 34) (target api level 34) directly from a unity build unity 2021 and newer go to project settings > player > android tab > publishing settings > build , and select both custom main gradle template custom main gradle template custom launcher gradle template custom launcher gradle template apply the following changes to both generated files assets/plugins/android/maintemplate gradle assets/plugins/android/maintemplate gradle assets/plugins/android/launchertemplate gradle assets/plugins/android/launchertemplate gradle if present because the project was upgraded from an older unity version, remove any block similar to the following commonly at the beginning of the file please note the airconsole sdk version 2 11 and before also provided these in its template, so when upgrading the airconsole unity sdk you need to remove these blocks from the templates buildscript { repositories { google() jcenter() } dependencies { // must be android gradle plugin 3 6 0 or later for a list of // compatible gradle versions refer to // https //developer android com/studio/releases/gradle plugin classpath 'com android tools build\ gradle 3 6 0' } } allprojects { repositories { google() jcenter() flatdir { dirs 'libs' } } } replace the following block if it is present } packaging options splits with the following block packaging options play asset packs splits to enable unity to work with android aab + pad unity 2019 3 and 2019 4 note the following customization is supported only by unity 2019 3 7f1 or later go to project settings > player > android tab > publishing settings > build , and select both custom main gradle template custom main gradle template custom launcher gradle template custom launcher gradle template apply the following changes to both generated files assets/plugins/android/maintemplate gradle assets/plugins/android/maintemplate gradle assets/plugins/android/launchertemplate gradle assets/plugins/android/launchertemplate gradle if present, remove any block similar to the following which are leftover from unity 2020 and before please note the airconsole sdk version 2 11 and before also provided these in its template, so when upgrading the airconsole unity sdk you need to remove these blocks from the templates buildscript { repositories { google() jcenter() } dependencies { // must be android gradle plugin 3 6 0 or later for a list of // compatible gradle versions refer to // https //developer android com/studio/releases/gradle plugin classpath 'com android tools build\ gradle 3 6 0' } } allprojects { repositories { google() jcenter() flatdir { dirs 'libs' } } } replace the following block } packaging options splits with the following block packaging options play asset packs splits to enable unity to work with android aab + pad unity 2018 3 or earlier, including 2017 gradle customizations are not supported on these versions of unity and are not compatible with the necessary changes to support android 13 (api level 34) build deliverables in order to be launched in the google play store , we need an aab file (as small as possible) the non data part may not be bigger than 150mb if your aab is bigger than 150mb and unity can not address it by using play asset distribution, it will inform you for more information, see unity documentation on aab and pad support in order to be launched in the amazon appstore , we need an apk file (as small as possible) apks may not be bigger than 100mb if your apk is bigger than 100mb, it needs to be split into an apk and an obb file to split it, simply check the split application binary split application binary checkbox in player settings > publishing settings for more information, see unity documentation on obb support airconsole is working with several distribution partners and not all systems support obb files if your apk's size exceeds 100mb, send us both the big, un split apk as well as the split apk and corresponding obb file android build system in order for video ads to be displayed correctly, the hardwareaccelerated hardwareaccelerated parameter in the android manifest needs to be set to true for the webview's postbuildprocess script to be able to overwrite the manifest, your android build system needs to be set to gradle (not to internal) you can set the android build system in the build settings or the android publishing settings if your game was built using the internal android build system before, you may have to delete your project's library folder to force an asset reimport check your android manifest you can use apktool to unpack your apk after building and double check your android manifest if hardwareaccelerated hardwareaccelerated is set to false, we recommend closing your project, deleting your library folder and making a new, clean build using the gradle build system when unity asks you if you want to upgrade the android sdk to 34, accept this and download the sdk known issues android studio error "installed build tools revision 34 0 0 is corrupted" or android studio error "installed build tools revision 34 0 0 is corrupted" this error can be solved following the link https //stackoverflow\ com/a/68430992 force sdk 34 as target version if you previously hardcoded it if for some reasons, you do not success in compiling to sdk 34 or in using the build tools version 34, you can edit assets/plugins/android/launchertemplate gradle assets/plugins/android/launchertemplate gradle and assets/plugins/android/maintemplate gradle assets/plugins/android/maintemplate gradle and hardcode the values compilesdkversion 34 buildtoolsversion '34 0 0' promo graphics android tv banner in your unity player settings, in the icon tab of the android export settings, check the 'enable android banner' 'enable android banner' checkbox and assign a cover art for your game this will be the icon that users see when they download your game onto their android tv please use the tv banner graphic preset provided here to adorn your banner with the airconsole logo google play visuals along with your apk, please provide the airconsole team with the following promotional graphics high res icon resolution 512 x 512, format 32 bit png (with transparency) feature graphic resolution 1024 x 500, format jpg or 24 bit png (without transparency) tv banner resolution 1280 x 720, format jpg or 24 bit png (no alpha) ingame screenshots x3 resolution 1920 x 1080, format jpg or png amazon appstore visuals along with your apk, please provide the airconsole team with the following promotional graphics app icon resolution 1280 x 720, format png (without transparency) background image resolution 1920 x 1080, format jpg or png (without transparency) promotional image resolution 1024 x 500 (landscape only), format jpg or png feature content background image resolution 1920 x 720, format jpg or png (without transparency) some content might be cut, or overlayed with icons, please have a look at the asset guidelines of amazon https //developer amazon com/docs/app submission/asset guidelines html help needed? if you are a developer and are experiencing issues with updating or implementing our sdk, please reach out to us at developers\@airconsole com for assistance we are here to help and will do our best to resolve any issues you may be facing as quickly as possible