Getting Yourself Started with Vuforia with Unity 2019 above (2020 updates)

So, why is this sudden post? Err well, if you install the latest versions of Unity, you will notice that setting up Vuforia will be a little bit different. We will need to use Unity’s Package Manager. So to update this new knowledge, here’s the new tutorial for how to get started with Vuforia. From now on, I will be trying to use Camtasia Studio this time to easily explain things. Leave your comments on how you like it, and how I can improve

Publishing Your Android App to Play Store – XZIMG Augmented Vision Tutorial 2 of 7

Registering For A Google Play Developer Account

Note: You would need to pay a 25$ registration fee in the payment step

Go to https://play.google.com/apps/publish/signup/ and sign in with your Google Account. If you don’t have Google Account, you need to create a new one.

An Agreement Page appears. Agree with the agreement and click Continue To Payment

A payment window appears. Complete the details and press Buy

Finally, after the payment, fill in the Developer Profile form and click Complete Registration

You will then be able to access the Google Play Console. This means your registration is now complete. You would notice though that there will not any app registered unlike my account.

Publishing our app to Google Play Console

Click Create Application

A window appears. Fill in the title of your application and press Create

Uploading the App Bundle (.aab)

Click App Releases

For the purpose of simplicity we will skip beta testing and assume that our program is already the Production version of things. Wooooow. Under Production Track, click Manage

Click Create Release

You will be asked to let Google manage and protect your app signing key, press Continue

Click Browse Files

A file window opens, select our .aab and click Open

Once upload is done, the Android App Bundle will be shown together with its version code and size.

Scroll down to What’s new in this release? Then type a simple description of the changes you made to the app. Since this is the initial release, lets type in “This is the initial release of the application” and press Save

We are not done yet, don’t click Review. Next, we will set a Content Rating

See you in the next part of the tutorial

Publishing Your Android App to Play Store – XZIMG Augmented Vision Tutorial 1 of 7

Introduction

In the previous tutorial post, I have taught you how to publish a test app to Android. In this tutorial we will cover the topic that is a must for developer creating apps for Android, which is Publishing your Android App to Play Store.

  • This tutorial will be broken down to 7 parts. They are:
    • 1 : Getting your app ready and publishing it as Android App Bundle (.aab)
    • 2: Registering Google Play Console account and uploading the aab
    • 3: Setting the Content Rating
    • 4: Setting the Pricing and Distribution
    • 5: Setting App Content description
    • 6: Setting Store Listing
    • 7: Final Steps and Publish!

Prerequisite

You need a few things in order to put your app to the Play Store. If you are not a graphics guy, you would need to ask a friend with such knowledge to help with the graphics part.

  • A privacy policy for your app. You can get one from https://www.websitepolicies.com/. Websitepolicies.com will provide you a public link to your policy. This is what you will need later.
  • Graphics for Play Store
    • 2 Screenshot of your application (Don’t know how to screenshot? Learn Here)
      • JPEG or 24-bit PNG (no alpha)
      • Minimum dimension: 320 px
      • Maximum dimension: 3840 px
    • 1 High Resolution Icon for your apps
      • 32-bit PNG (with alpha)
      • Dimensions: 512 px by 512 px
      • Maximum file size: 1024 KB
    • 1 Feature Image
      • JPEG or 24-bit PNG (no alpha)
      • Dimensions: 1024px by 500px
  • Descriptions for your App
    • 1 Title (The name of your app)
    • 1 short description of your app (80 characters max)
    • 1 long description of your app
  • Note: All your descriptions must not contain:
    • User testimonials
    • Excessive details
      • OK : “This is an AR app on cats, for cat lovers”
      • Don’t: “this is an AR app on cats, brown cats, blue cats, silver cats, cat food , cat drinks, cats getting drunk in a bar and starting a fight, and many other cats”
    • Misleading references to other apps or products
    • Repetitive, excessive, irrelevant keywords, keyword spamming
  • Avoid including these:
    • Sexually suggestive images
    • Profanity and vulgarity
    • Graphic violence
    • Depictions of illegal drug use

Preparing for our App for deployment

Go to File > Build Settings > Player Settings

Change the App icon

Drag and drop your created app icon into Assets folder in Unity

Drag and Drop the icon to the Default Icon in the Project Settings

Creating a Keystore

Under Publishing Settings, Click Keystore Manager

In the Keystore Manager, Click the Keystore menu and select Create New > Anywhere

A save file window appears, save this keystore file somewhere safe.

Do not, i repeat do not lose this keystore file. Backup it multiple times! Without this keystore you will permanently unable to update your application. Both in Unity and in Play Store.

Next, we need to fill in the details as explained by the picture example below

Click Add Key

A keystore created confirmation window appears, click Yes

The key has now been set, under Project Key, click the Alias menu and select our newly created key value

Building our Google Play App Bundle

In the Build Settings window, select Build App Bundle (Google Play), then click Build

A save file window appears, select a folder to put the built file in. In my example, i put it in a new folder named AAB. Click Save

Once done, you will have an aab file in your folder

This is the end of Phase 1, in Phase 2, we will upload our app into the Play Store

How To Install Unity with Mobile (iOS and Android) Build Support

This is a general tutorial on how to install Unity with Android Build Support. This is intended for those following my AR tutorials, but this works just as well if you just want to install Unity.

Download and install Unity Hub

Go to unity3d.com/get-unit/download

You will see two options. One is to install Unity only, second is to use Unity Hub. Download and install Unity Hub

Why Unity Hub?

Unity Hub allows you to manage and install addons and plugins easier. It will also help maintain multple versions of Unity. Why? Later on in your development life you will realise that unfortunately different people uses different versions of Unity for development. With the hub you can install their versions too, and access their project without screwing up your own project that uses your version of Unity

Installing the latest Unity in Unity Hub

Start up Unity Hub, you will see something like this. Press Add

Add Unity Version window appears, select the latest release of Unity and click Next

You will be asked which components to install. Make sure the options shown below are selected. Then, click Next

Unity will begin downloading and installing. Once done, it will look like this picture below.

That’s all on how to install Unity for Mobile Development

Building a test build of our project on Android

Prerequisite

To follow this tutorial, you need to complete the previous tutorial on building our application on PC

Switch the Build Settings to Android

Go to File and select Build Settings

The Build Settings window appears, under Platform, select Android and click Switch Platform

Unity will start to switch the application to Android format

Once the switch is completed, under Platform the Unity icon will now appear at the Android instead of the PC

Customizing the Android player settings

Press Player Settings

Player Settings window will appear. Change Company Name, and Product Name to your own name

Check that App Orientation is Potrait

Press Resoultion and Presentation to expand its settings

Under Resolution and Presentation, make sure the Default Orientation is Potrait

Adjusting Other Settings

Press Other Settings to expand its settings

It will expand into a looong settings to something like this

Changing our Package Name

In the Package Name slot, change the Package Name to the format of com.yourcompanyname.product. For an example I used com.mycompanyyeah.test1.

Important Note! Pay Attention yeah:

  1. Your Company Name and Package Name, should be the same as previously entered at the Company Name and Package Name slot
  2. No spaces are allowed!

Set Scripting Backend to IL2CPP

Make sure the Scripting Backend is IL2CPP

Set Target Architecture

Check ARMv7 and ARM64. ARM64 is compulsory as now Play Store will only accept app that support ARM64. ARMv7 is selected so that we can support older devices.

Press Build Button to Build our apk

Select where to save the .apk

A window appears, lets put our apk to the desktop

The APK will start building

Our test APK will appear. Copy it to your Android Phone and install it

Don’t know how to install an APK? Click this link and read the tutorial here

Testing our AR on Android

Run our installed Test App and scan our Image Target. It should work now. Yeah!

Simpler Vuforia Event Handling using Unity Events

Edit 2021 Update:

Notice, this codes are no longer needed as Vuforia has provided their own Unity Events Handler. So If you are using the latest Vuforia, it comes built in. It looks like the picture below and it works exactly the same as the one I wrote here.

This post below is still kept as there are people still struggling to update their old projects, so this is for you guys/gals in University, hope you can update soon!


Do you ever wish that Vuforia event handling is as simple as using the OnClick() property in Unity UI’s Button? Wish no more bros and sis. Here the code, and explanation on how I did it.

The Code

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using Vuforia;

    public class EasyEventHandler : MonoBehaviour, ITrackableEventHandler
    {

    public UnityEvent onMarkerFound;
    public UnityEvent onMarkerLost;

        protected TrackableBehaviour mTrackableBehaviour;
        protected TrackableBehaviour.Status m_PreviousStatus;
        protected TrackableBehaviour.Status m_NewStatus;



        protected virtual void Start()
        {
            mTrackableBehaviour = GetComponent<TrackableBehaviour>();
            if (mTrackableBehaviour)
                mTrackableBehaviour.RegisterTrackableEventHandler(this);
        }

        protected virtual void OnDestroy()
        {
            if (mTrackableBehaviour)
                mTrackableBehaviour.UnregisterTrackableEventHandler(this);
        }


        public void OnTrackableStateChanged(
            TrackableBehaviour.Status previousStatus,
            TrackableBehaviour.Status newStatus)
        {
            m_PreviousStatus = previousStatus;
            m_NewStatus = newStatus;

            if (newStatus == TrackableBehaviour.Status.DETECTED ||
                newStatus == TrackableBehaviour.Status.TRACKED ||
                newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)
            {
                onMarkerFound.Invoke();
            }
            else if (previousStatus == TrackableBehaviour.Status.TRACKED &&
                     newStatus == TrackableBehaviour.Status.NO_POSE)
            {
 
                onMarkerLost.Invoke();
            }
            else
            {
            // For combo of previousStatus=UNKNOWN + newStatus=UNKNOWN|NOT_FOUND
            // Vuforia is starting, but tracking has not been lost or found yet
            // Call OnTrackingLost() to hide the augmentations
            onMarkerLost.Invoke();
            }
        }
    }

How it looks like

Explanation

Creating the Unity Events and Exposing it in Inspector

This code uses the UnityEngine.Events . Firstly, I create two UnityEvents variable, and make the variables public, doing this I get to expose the events, giving you that familiar On Click () thingy in Unity UI Button.

    public UnityEvent onMarkerFound;
    public UnityEvent onMarkerLost;

Invoking the Events when marker is detected and lost

Then, OnTrackableStateChanged, if the Image Target is detected, I use the UnityEvent’s Invoke() function to Invoke the event, this will then work just like the On Click ()

That’s all folks…… enjoy!

Quick AR Creation Tip: Have a “toolbox folder”

If you are like me and have a lot of things to do with so little time ( that’s the way we like it!) having a “toolbox folder” saves you effort. In this post I will share what I have inside my toolbox folder.

I’m not saying this is the best way but I have a toolbox. This have almost everything I need, scripts I built from all these year so I just drag and drop my toolbox into Unity and I am ready to go!

I have one for each engine that I use. Here is what it looks like:

I have one toolbox for each engine. Ready to drag drop into Unity

A look into my Toolbox

Storage Template

When building anything in Unity, regardless what engine you are using it important to be organized. So my folder structure is something like this:

My folder structure

But I did not create it from scratch every time I am working on something. It is already arranged like so inside my toolbox. So, when I drag my toolbox in and all folders will be there ready to go.

The folders are already there ready to go

Ready Made Modular Scripts

Most of the things that we need to do in AR are quite repetitive in some sense or another. So, i build modular scripts that allows me to achieve an interaction quickly by drag drop a pre-made script and assigning the values in Unity.

Ready Made, modular scripts

Image Target Template Script

Image target template script is my default drag to a Vuforia Image Target. I rarely code interactions since the time I have this. It has all my basic functions like play animations, audio and event handling. Sometimes, this is all I need.

Image Target Template S

Audio Manager Prefab and Mixer

To avoid the repetitive task of managing and creating Audio Sources, All my Audio is managed by a pre-built AudioManager that has a group of AudioSource underneath it. The Audio Manager prefab is attached to the AR Camera so I won’t have volume problems. The AudioManager script has two functions:

  1. Control the play,pause etc.
  2. Allows me to play through an Audio Source based on ID. Hence, avoiding conflict that sometimes causes no sound to come out.

I usually need just 10 channels as most of the time, I don’t play more than 10 audio at the same time.

Audio Manager, It sits under the AR Camera

Conclusion

I am not actually preaching anything just sharing how I do things just so that it might be useful for everyone. Our workflows might not be the same so it is better to build your own toolset. I’m just showing this as an example.

What are your tips to make AR creation faster? Do comment below on what you think.

Arcolib (Edited 31st july 2019)

Edit : Today is a really sad day. I found out that Arcolib so far did not update their software yet to support the ARM64 architecture. That means we can no longer use Arcolib for Android apps and Apple apps soon. It will still work on Desktop soluions though. Play Store will start to enforce the removal of non ARM64 apps by August 1 this year. Exception is given for apps that is built using Unity 5.6.7 and elow until 2021. Lucky break for me coz my app are created using 5.6.7. Don’t judge me…, if something works i don’t touch it and I still keep the content updated.

Arcolib

First thing first: I know what you are thinking, he’s paid to blog this. Nope. This is just my view of Arcolib. One of my go-to solution for Simple to Intermediate AR applications.

Arcolib is found hiding among the waters of the Unity Assetstore. I happened to type Augmented Reality one day in the search box and there they are.

Cheap, simple, and good enough

I am a Vuforia user as well so i do have bias towards it there. But for simple, low cost projects I would go for Arcolib. It has seamless import into Unity, the event handling is okay once you get to know it, and there are examples to help along the way. Without being too babbly, i will try to tell what i really like about Arcolib

In-Unity Marker Generation

One of the things that draws me into Arcolib is the in-Unity marker generation. Image Targets can be created inside Unity, which is a godsend for people who like to work at cafes and random places where internet connectivity is a question mark. The ImageTarget generation is really fast and you can bulk generation markers from a selected folder. You can generate their version of barcode markers too. Handy if you are juggling a museum level Augmented Reality

QR Code as marker

One thing i like about Arcolib is the ability to use QRCode as markers as-is so no need to install 3rd party QR reader and stuff. This feature is especially useful when,  again you have so many items to show Augmented Reality of.

Some aspects that they could improve on

Number one in the fix it list is the demos. If you are reading this dear Arcolib devs, please craete a starter kit, name it starter kit, so that when i start i would already have an AR with Image markers, with animated model capability, and sound playing capability in one scene. So that i could just duplicate that particular marker, swap in my stuff and i’m ready to go. You are seriously missing out man. If there are template based development like that AR would be a lot easier for beginners and educators, the kind of people you should be going for as target market. They are teachers and beginners, many of them whom i taught say they do not have a lot of money but can afford your software.

Conclusion

If  you are developing simple AR and the project budget does not allow for you to use high-end AR SDK, this is a good Simple-Interdiate level solution if you just need Image based or QR based AR.

Note: You can find Arcolib from Unity Assets Store

Where to purchase assets for AR and VR

In order to build Augmented Reality, and Virtual Reality you will need resources. Usually, the best way to have an asset is to create one. But for some projects, a shortcut won’t hurt. Why build if you can buy the assets? Here are the main places that I shop around for my projects.

Unity Assets Store – The All In One Go To Marketplace

Since I use Vuforia + Unity combination a lot. This is where i go to shop for my assets. From low poly 3D models, to textures, designs, UI and other features. The best part is, if you buy it from here it will almost most of the time work for Unity, since it is developed for Unity.

Low-poly 3D Models

3D models are the core of our experiences most of the time. When I look for 3D models, I will habitually look for low-poly 3d models. These are the best because highly detailed, high poly models will be very heavy for our 3d engines to handle.

CGTrader Low Poly

CGTrader is my main source of low-poly 3d models outside of the Unity Assets Store. They provide various assets, animated and non-animated for you to use and they also provide conversion services if the asset is not available in your preferred format. Very helpful indeed. Some of them will require further processing, others are ready to import into our tools like Unity

Music, Sound Effects and Ambience

AudioJungle

You can find all sorts of sounds from the marketplace at AudioJungle. It comes with flexible licensing for different commercial applications.

Ready Made Codes and Templates

Yep you read that right sometimes its easier to have something to start with and just edit out some minor details instead. For this purpose, you need ready made codes and templates.

CodeCanyon

CodeCanyon has the templates and pre-made codes for you. Whether you need one to see how things work for reverse engineering or to make your work go faster try checking out this site to see if there are codes that you can purchase and use. Saves a lot of time.