Using Unity to Develop Applications. Getting Started with Android Development How Unity for Android differs from the desktop version

Post Views: 12 544

We talked about how you can create your own game on Android using the Unreal Engine. In this article, we will look at another equally popular game development engine - Unity.

Unity is a very famous engine among indie developers. Basically, it is a cross-platform engine that allows you to develop 3D- and 2D-games. A feature that sets Unity apart from the rest of the engines is the low barrier to entry for beginners with a rich toolkit for professionals. Cross-platform, on the other hand, allows you to develop applications for any platform, from desktop games to mobile.

It is worth mentioning the subscription system separately, since Unity is not a completely free product. There are several types of subscriptions:

  • Personal... Free version that contains all the main features of the engine. Has the following limitation: income per year or the amount of funds raised must not exceed 100000$ .
  • Plus... Behind 35 dollars per month various reports and analytics are provided, as well as the ability to change the splash screen, 20% -th discount on purchases in Asset Store and various minor benefits. Has the following limitation: income per year or the amount of funds raised should not exceed 200000$ .
  • Pro... Behind $ 125 per month includes all the benefits of the version Plus and additionally professional service and premium support. No restrictions on turnover or amount of funds.
  • Separate versions for business (used by large companies).

Thus, for indie developers on small budgets, version Personal or Plus, otherwise you will have to subscribe Pro... In this article we will use free version for the first launch.

Step 1. Installing Unity

In order to start installing Unity, you need to go to the Unity Store website, where you will be prompted to select a subscription type. As mentioned above, we choose Personal.

You will then be prompted to accept the terms of use and download the installer. You can also see system requirements to work with Unity.

After starting the installer, you will be prompted to select which components you want to install. Since we need to create an application for Android, check the box for Android Build Support... Also, if desired, instead of with Unity, you can install Visual Studio Community 2017 for programming on C #.

After that, all that remains is to choose the installation path and start installing Unity.

Step 2. Register and configure Unity

After finishing the installation and launching Unity, we are invited to log in with our account.

Then again you will be prompted to select a subscription, we will also focus on Personal. In this case, you will need to confirm that the company has an annual income of less than $ 100,000 or that Unity is used for training purposes.

At the end, you are invited to take a small survey in which you need to answer what you are doing and why you are installing Unity.

Step 3. Creating a new project

Having configured Unity, we get to the project selection \\ create screen. Here you need to click Newto create your new project.

After that, in the window that appears, you are prompted to enter the name of the project and the directory where it will be located. Also don't forget to check the box 3Dto use the editor in 3D.

When you're done, click Create projectto create a project. After that, an editor window will open with a pre-generated scene.

We will not yet deal with the intricacies of programming and take a finished game as an example. For this there is Asset Store, which contains a huge number of ready-made models, animations, sounds (and even games), both paid and free.

To open the Asset Store, you need in the menu Window choose Asset Store (key combination Ctrl-9).

The shop window will open. Let's enter in the search bar “ flappy bird style example game»And open a free example that we will use in our project.

By clicking Download and thus having downloaded it, you can then import it into your project. To do this, click Import, after which a warning will appear stating that the project settings will be changed after import.

After agreeing to import, you will see a window in which you need to select which components to import. Select everything and click Import.

After the import is complete, you will see the new files in the Project Explorer. These are the game files. To open the scene in the editor, expand Flappy bird styleScenes and double click on Main.

As a result, the game scene will appear in the 3D editor window.

You can check how the game works right in Unity by clicking on the button Play above the editor window.

Step 4. Configuring Android Tools

Note: if you use Android Studio, then you already have all the necessary components installed and therefore you can safely proceed to the next step.

In order to build the resulting game on Android, you need to install the following tools:

  • Java Development Kit (JDK). You can download it from the Java website. By clicking on the link, you will see at the very top Java Platform (JDK), click on Download next to the label, then select your operating system and start downloading. After that, just follow the instructions of the installer.
  • Android SDK... The most in a simple way to install the current version is to download Android Studio with which this SDK comes with. To do this, go to the Android Studio website and click Download Android Studio... The Android Studio installer installs the core Android SDK components required for Android development.

Step 5. Preparing the project for launch

First, you need to change your development platform to Android. To do this, in Unity, open the File menu and select Build Settings.

In the window that appears, select Android and then press Switch platform.

The platform switch tells us that we will be building an Android app. This means that when we build the application, Unity will create APK file... The platform switch also forces Unity to re-import all project assets. It won't take long on a small project, but keep in mind that on large projects this operation can take a long time.

Now we need to provide a package name for the application.

Note: The package name is a unique identifier for the application, it is written in reverse DNS style in the format com.CompanyName.ProductName... After publishing the app to Google play the package name can no longer be changed.

To do this, go to the menu Edit and choose Project Settings - Player.

On the right side of Unity, a window will open with many different settings, such as application version, target and minimum SDK, icon selection, etc. Here we need in the block Other Settings to find Identification and set the package name in the field Package Name... Other parameters can also be changed if desired.

Now all that remains is to specify the path to the Android SDK and JDK. To do this, go to the menu and select Edit - Preferences.

In the window that appears, go to External Tools and in the fields SDK and JDK specify the appropriate paths and then close the window.

Step 6. Build and run the application

It's time to build your first Unity application. To do this, select from the menu File - Build Settings... A window will open, in it you will need to add a scene that needs to be assembled. Since we already have this scene open in the editor, just click Add Open Scenesto add it to the assembly, after adding you will see it in the list of scenes.

It remains only to press Buildand then Unity will start building the application. Before that, you may be asked to select the folder where the collected application files will be saved, as well as the name of the APK file.

Note: at the moment if you have an alpha version installed in the Android SDK Build-Tools (version 28.0.0-rc1), when building Gradle, it will give an error. To fix this, simply remove that version from the Android SDK.

As a result, the assembled APK file will appear in the folder you specified, ready for installation on an emulator or on a real device.

Let's see what's inside the assembled APK. To do this, we will use the utility APK Analyzerwhich is included with Android Studio,

The uncompressed APK file size is 21.1 MB, in compressed 20.9 MB... As you can see from the graph, most of the volume is taken up by third-party libraries added by Unity. Then in assetsall resources that are used in the assembled scene are located. File classes.dex contains all 89 classes and 479 methods.

Also, if you look into AndroidManifest.xml, the application consists of one activity.

Conclusion

That's all. In this article, we learned how to install and configure Unity, and also put together our first Android app.

Developing games for Android OS devices requires a similar approach to developing for iOS. On the other hand, the hardware of Android devices is not subject to strict standards, which forces us to solve issues that are absent when working with iOS. There are also differences between the Android and iOS versions of Unity.

Preparing the Android development environment

Before you can test your games on a device, you will need to prepare your development environment. Specifically, download and install the Android SDK of the desired platform and add your device to the system (this process is different for Windows and Mac). This is described in detail on the Android developers website, and your device manufacturer may provide additional information. Since this is a rather complicated process, we have prepared a small instruction that will help you prepare everything you need for development. If you need more information, you can get it on the Android Developers Portal.

Accessing Android functions

Unity provides an API for accessing Android inputs and settings. The available classes are documented in the Writing Code for Android Assemblies page.

Binding C, C ++ or Java code to scripts

Unity allows you to call functions written in C / C ++ directly from scripts (Java functions can be called indirectly). To learn how to access functions from native code from Unity, visit the building plugins for Android page.

Occlusion Culling

Unity provides occlusion culling support which is very useful when optimizing for mobile platforms. More information can be found on the Occlusion culling page.

Setting up the splash screen

The splash screen that appears when the game starts can be customized - see this page for more information.

Troubleshooting and error messages

There are many reasons for your application to crash or not work as expected. Our Android specific troubleshooting guide will help you figure out the root causes of errors in no time. If, after reading the manual, you suspect that the problem is in Unity, you should write a bug report. See this page for instructions.

How Unity for Android differs from the desktop version

Strongly typed JavaScript

To improve performance in Android Unity, dynamic typing is always disabled in JavaScript (as if #pragma strict were automatically applied to every script). This is important to remember if you are porting a project to Android from older platforms, and if you encounter compilation errors, the problem should be looked for first of all in typing. Such errors are usually easy to deal with by making sure that the types of all variables are explicitly specified or coded during initialization.

While Unity Android supports DXT / PVRTC / ATC textures, Unity will decompress textures to RGB (A) format at runtime if these compression methods are not supported on the specific device. This can seriously affect GPU rendering performance, so it is recommended to use the ETC format. It is the de facto standard for Android, and should be supported by everyone modern devices... On the other hand, ETC does not support an alpha channel, and sometimes 16-bit RGBA textures will be the best choice for quality, size and rendering speed where an alpha channel is needed.

Unity Web Player is a player for 3D games.

Every day a wide variety of games, applications and programs appear on the Internet. Some of them do not take root and do not find their fans, while others gain regular users who require continuation from this product, quality and the ability to play and use all available operating systems and devices.

Each application has its own ideal platform.

Each new product is developed on a specific platform, which in the future may require special capabilities from your computer, smartphone or tablet. Recently, the Unity3D program has begun to be very popular, with its help you can independently create and develop games in three - and two-dimensional graphics (of course, this requires programming skills). But it's not just the existence of these opportunities. And the fact is that in the world of computer games there are already applications created with the help of Unity3D, and in order to start the gameplay in the appropriate quality, a special player is needed.

Install a dedicated player to play games.

U will help you with this nity Web Playerwhich is also available for Android OS. There are versions for PC, they differ in their sizes. For mobile devices, such an application does not take up a lot of memory space, thus it will not overload or slow down the workflow. It should be said right away that this player works well on all versions that are not lower than 2.3. When installing it on your device, you don't need any special knowledge. All you need to do is wait for the full download. You don't have to worry about whether the this application with your browser, because it automatically syncs with it and serves as a great addition to whatever version you use. The situation is the same for updates. If there is a new one Unity Web Player - when connected to the Internet, it will update itself, without your participation.

Great helper for playing 3D games.

Its main function is to reproduce in good quality games 3D graphics. If you want to play online (and you need this player for this), it will automatically start on your device and you can enjoy the game. If suddenly you have problems with this (although this is a rare occurrence), you can find all the answers to your questions by looking at the YouTube pages (you will be shown in the video how to solve the problems). Its positive side is that you can play and view information in your browser window (with a constant Internet connection).

Otherwise, this player is very easy to use. Many game lovers actively use it on their mobile devices... This is especially true in an era when 3D graphics supplant other types. The fact that it weighs little and does not require you to follow its update only adds to it pluses.

If you are a fan of 3D games and applications - install unity player on Android and enjoy the gameplay in good quality. Good luck to all of you!

Unity Web Player 5.3.7.0

Unity Web Player free download Unity Web Player

Unity Web Player is an application for Windows, or rather a browser extension required to play content developed in the Unity environment. Initially, gaming applications for smartphones were developed in this environment, but due to the simplicity and ease of development, Unity was developed as a separate application - Unity Web Player, which can be downloaded for free from the link at the bottom of the page.

Unity web player made a small revolution, with its help it became possible to play modern online 3D games with excellent graphics right in the browser window. The only condition is that the game must be developed on the Unity platform. At the moment, the number of such games is constantly growing, the platform allows you to develop games of any genre: shooters, RPGs, strategies. Among them there are hits - Vega Conflict, TrackRacing Online Pursuit, Digger-Online, Contra City, City of Steam.

Unity web player is free to download, all are supported windows versions and Mac, installation is very easy and no configuration is required to expand, so you can immediately enjoy high-performance gaming and high-quality graphics. These are not all the advantages of the Unity web player, games on this platform have realistic physics and show excellent performance even on older PCs.