Hiatus

I haven’t posted in a while. This is due to the fact that I’ve been doing some thinking about the future of this blog. Although I enjoy writing posts I started to feel that I was focusing on writing posts more than producing apps. I want to get back into app development so something has to change. Unfortunately, this will mean posts to TI will cease for the foreseeable. I’ll still post development updates but will utilise the Junction 5 blog, after all that’s the portfolio I’m building up.

I plan to do this for a year. I figure if I put a timescale on it it’ll stop me taking three years to produce something.

So that’s what’s going on with me, you know as well as being a mum and going back to work from September.

Good luck with your Unity app projects.

Follow my progress on the Junction 5 blog.

See you in a year!

Impact on build size using a template project

It seems that by trying to save time creating a template, I’ve been causing an issue within my Unity project even before I begin coding.  Because currently it’s simply not easy to remove packages once they’ve been added to your project, once I’ve added 5 packages that could be used in my template I’m stuck with them whether they are used or not. This means that a considerable number of DLL’s are being referenced that may not be required. And, as I learned after researching how to reduce a build size, each DLL’s you have referenced could add an additional MB to your build.

What’s my solution to reduce the build size while still using a template?

I have two ways around this. The first is to make an empty project with only Google mobile ads set up. As everything else could be set up within 15 mins so not much time is lost by adding these as and when to my projects.

The second is to actually abandon the use of a template and think of the long term goals of each project and whether having ads in my projects are as necessary as an in-app purchasing method. Both are great for “free” apps but do ads really generate me enough money to warrant them being in every app I create and potentially putting off users? These are the different business models I’ll have to consider moving forward.

Findings?

After doing this I found that the build size was much smaller than my previous template build. So bear in mind that even if you don’t use a package’s contents you may be adding to your build’s size anyway. Only unpack additional assets that are necessary.

Reducing the size of your Unity build

In a previous post, I mentioned that I was building a template app to contain features that I would use frequently across projects. I added the relevant plugins (Unity Analytics, Chartboost, Google Mobile Ads and Soomla) and created an Android build. Although this worked when I went to check the size of the application I was stunned to see that without any content (graphical or textual), the app was already 46.77MB.  This was already almost double the size of my Werdz Movies app.

So I decided to create a couple of test projects to narrow down what I could do to reduce the size of the app.

Unfortunately, I found out that the Unity engine is packaged into builds for the personal version of the engine, but is stripped out for the Pro version. So what do you do to keep your app’s final size down?

How to reduce your build

Using various sites I came up with the following changes I could make to my app in order to reduce the size of the development build. These changes have yet to be tested on signed builds ready for upload to Google Play or the App Store but the smaller your app is at this stage, the more chance you have at delivering the smallest app to the stores.

  • Remove all non essential test images
  • Ensure test images are of power of two (POT) size so that Unity3D can use PVRTC hardware compression. Non POT images will end up as uncompressed, true color images.
  • Reduce the max size of images once imported
  • Compress the images
  • Reduce size of audio resources
  • Reduce the amount of DLL’s referenced (each one used adds an additional MB!)
  • Select release build instead of debug build
  • Use .NET 2.0 subset in the Player Settings
  • Don’t use JavaScript arrays during development
  • Don’t use .NET classes that are outside mscorlib
  • Make the target device in Unity Settings specific if you can e.g. only iPhone.
  • Set the Target Platform in Unity Settings to AR Mv 7 (Device Filter setting)
  • Change the install location to External
  • Change the stripping level to use micro mscorlib.

Remember to check the build log to see which assets are contributing the most to the size of the build.

After I had made these changes, I found that an empty project produced an app of 10.4 MB which once built to the device was 27.87 MB.  My project went down to a 12MB app.  This went to 37.79 MB when built to a device (again, this is without content and any major graphics added).

So I have a bit more investigation to go because I think this may simply be the best I can do. Or, do I find the cash and invest in the Pro version?

Have you had similar issues that you’ve overcome? Please feel free to leave me a comment below or email me.

For more information see the Unity Manual articles Reducing the File Size of the Build for builds to and platform and Optimizing the Size of the Built iOS Player for builds specifically to iOS.

Developing an app template

So in between looking after my baby and redecorating my house, I’ve been building a small app template to use as a base for future projects.

Why create a template?

The idea is to add in the features that I’ll use often e.g. the analytics.  Then once I have the app idea fleshed out, I can plug in specific uses of the features into the app, like custom analytics events. This means I won’t need to set up the basics for every project.

What packages did I include and why?

Integration

Getting Parse (Data) up and running was fine. Data was being sent and stored correctly. I only wanted Chartboost for it’s interstitials and those seemed to launch fine after a short set up.  Integrating Unity Analytics was also very simple.  The dashboard looked a bit bland but as it’s a beta I’ll let them off.  Once I get my first app set up I’ll go through the process of setting up custom events to see if it’s as easy to do as in Game Analytics.

Problems with iOS build

I encountered 19 issues when building my iOS project in XCode. Looking at some of the errors, it seemed like Parse could’ve been an issue so I removed the game object containing the set up code.

The template project didn’t need Parse. It was just a good feature to get integrated from the start. So I removed it an attempt to debug the iOS build.  But after a rebuild of the project, I found that this didn’t make a difference.  So after more investigation I hit the following issues and solved them with the solutions below.

Error: “use of @import when modules are disabled error”

Modules are enabled by default in new projects since XCode 5 but I found that my project had these options disabled. To enable them, go into your project Build Settings, search for “Modules” and set “Enable Modules”, the “Link Frameworks” and any other options under this section to “Yes“.

For more information see these steps.

Error: “Module ‘GoogleMobileAds’ not found”

This was appearing because I had omitted to manually add the framework into the iOS project.  To add the sdk manually follow these instructions.

Download the latest sdk for iOS from here.

After a rebuild in XCode these errors went away and built successfully to my device.

Problems with Android build

When trying to build the apk in Unity I kept getting an error with the Android manifest merging.  This was missing from the file:

<meta-data android:name=”unityplayer.ForwardNativeEventsToDalvik” android:value=”true” />

However, when I did as instructed the error still appeared after each build even though Unity showed the build as successful.  I also found that the Chartboost ads were showing despite the error stating that these wouldn’t appear.

I felt that banner ads were a required feature for this template but Chartboost wasn’t so I commented out the code to launch the Chartboost ads to try and solve this issue.

After many attempts with the manifest file I still got the same error. It was only until I changed my entire manifest file to the following that it all worked:

<?xml version="1.0" encoding="utf-8"?>
<manifest
 xmlns:android="http://schemas.android.com/apk/res/android"
 package="com.unity3d.player"
 android:installLocation="preferExternal"
 android:versionCode="1"
 android:versionName="1.0">
 <supports-screens
 android:smallScreens="true"
 android:normalScreens="true"
 android:largeScreens="true"
 android:xlargeScreens="true"
 android:anyDensity="true"/>
 
 <!-- Google Mobile Ads Permissions -->
 <uses-permission android:name="android.permission.INTERNET" />
 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

 <application
 android:theme="@android:style/Theme.NoTitleBar"
 android:icon="@drawable/app_icon"
 android:label="@string/app_name"
 android:debuggable="true">
 
 <!-- meta-data tag for Google Play services -->
 <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>
 <activity android:name="com.unity3d.player.UnityPlayerProxyActivity" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" >
 <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
 </activity>
 <activity android:name="com.unity3d.player.UnityPlayerActivity" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" >
 </activity>
 <activity android:name="com.unity3d.player.UnityPlayerNativeActivity" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" >
 <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
 <intent-filter>
 <action android:name="android.intent.action.MAIN" />
 <category android:name="android.intent.category.LAUNCHER" />
 </intent-filter>
 <meta-data android:name="android.app.lib_name" android:value="unity" />
 </activity>
 <activity android:name="com.unity3d.player.VideoPlayer" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" >
 </activity>
 </application>
</manifest>

So now my Android and iOS build was working with no errors. Time to start project 1!

Debugging your Unity project using Monodevelop

Debugging is the process of reading the code of software in order to find, fix and resolve issues so that the software functions as intended.

When you are creating any piece of software whether it’s an app or game it’s important you have an IDE and not just a code editor to be able to debug your code.

Using Monodevelop compared to Visual Studio

I (like most people I’m sure) am used to using Visual Studio to code in. Unfortunately, without a virtual machine I can’t run Visual Studio on my MacBook. Luckily MonoDevelop comes installed along with Unity and runs on both Windows and OSX devices.  To debug a program with Visual Studio you attach to a running process.  You do the same using MonoDevelop. To attach to a running process press the Play button at the top left of the window in the version of MonoDevelop that comes pre-installed with Unity 5.  A list of the currently running processes will be listed. Just select the instance of Unity that you’re running from the list of processes and when the debugger I’d attached the Play button will change to a Stop button.

Always remember to attach to the correct process!

A mistake I seemed to make early on was to try and debug without attaching to a currently running process (something that the updated version of MonoDevelop with Unity 5 seems to have made impossible now). I thought that MonoDevelop would just detect the Unity instance running and link to that. I was wrong. You still need to tell it where to connect. So because I didn’t direct it, this meant that a new instance of Unity was launched that was attached to MonoDevelop.

This wasn’t helpful .

Work backwards and open MonoDevelop first

To ensure you are always attached to the correct instance of Unity when you debug, you can always launch MonoDevelop first then try and debug. Because a process is not attached you can choose to open a new instance of Unity and you will be able to debug your project.

For more information, see Unity’s MonoDevelop Debugger page.

Push notifications packages for Unity projects

The way that we are using apps are changing. When apps were first introduced, we always needed to open an app to check for any updates. With the introduction of push notifications you got an update from apps when they happened, as well as when they were opened.  This allowed you to check your update but meant you needed to open the app to respond. Now, app developers are going one step further. You are now able to respond to your update via the notification. Depending on the app will determine what functionality they have implemented to allow you to respond.  This is seen more within devices running Android Lollipop and iOS 8+.

Having a push service within your app, although may not be an essential day one release feature, however it will allow you to engage with your users in another way. And the more ways you keep in contact with your users, notifying them of important updates without having them directly open the app, the more likely they are to continue using your app.

Push Services for Unity projects

Here are a list of push notification services that provide Unity packages ready to be incorporated into your Unity projects.

Your thoughts

  • What’s your experiences with the above services?
  • Are you using other push notification services in your Unity made apps?
  • What’s your opinion on their service?

Using Google Sheets to update your app content

As I mentioned in my post about ways to store content in your mobile apps, using external tools like Google Sheets can be used to manage your game data.

Why would you do this?

  1. If your app’s content will benefit from live adjustments such as in games like MMOs where the day-to-day changes in player behaviour effect the story and gameplay.
  2. If your app has a lot of content it may be a good idea to store this data in something external but still accessible to the app.  This means that the size of the app you submit will be as small as possible.
  3. If you use an online spreadsheet like Google Sheets to manage your app’s data, the work can be shared between team members because it’s accessible to everyone.  But access can also be restricted to specific individuals.
  4. Using the Google Sheets app and web app also allows you to update content for your apps even when you’re not connected to the internet.
  5. Having data stored in a simple, everyday system like a spreadsheet means that even non-technical people aiding you on your project are able to carry out updates.
  6. Lastly, and probably most important, you are able to update the app’s data to players without re-submitting to the app stores.

So these are all great reasons why you should store your data in an online spreadsheet like Google Sheets.  But what are some of the issues to consider?

Things to keep in mind

  • You need to get that data into the game per session. With a large amount of data this could mean long syncing times.  You need to wary of this as long loading or data sync times may put some users off and may give up using your app.
  • The structure you use to store the data needs to be efficient to ensure the speed of the app isn’t compromised at runtime.  Even after the data has been synced and the app loaded it’s important to maintain a fast speed.
  • Easy to get incorrect data fed into game if you have no safeguards in place.  Ensure people always check what they update before it’s committed.
  • Unless you set up a robust security system you may find your data isn’t completely private.  Those with the knowledge of Google Sheets may be able to access your app’s content.

You are the only person who can decide if the pros outweigh the cons.  If you have a small enough number of users you could always store the content on Google Sheets first.  Then if your app gains popularity consider switching to a more secure way to manage your content or set up scripts to ensure your documents can only be accessed by certain people.

How do you connect your Unity project with Google Sheets?

You can connect your project either by writing your own module to connect to the Google API or buy one of the solutions already made within the Unity Asset Store, like the asset Google Sheets For Unity.

From my experience, Google Sheets for Unity was well documented, the developer was easy to get hold of and extremely helpful. Integration took less than 15 minutes and adapting the code to pull in different data types only took an additional 20 minutes. The code is well written and I would recommend this asset to anyone wanting to use Google Sheets to hold their app content.

What are B2C apps?

Thousands of apps are uploaded to the App Store and Google Play every day. The audience that your app is aimed at will determine whether it is a B2B or a B2C app.

What is B2C?

B2C stands for business to consumer. A business sells products or provides services directly to the end user. These are usually individuals who are everyday people.

When you produce an app where the customer is the consumer this is a B2C app.