Monday, November 3, 2014

Get it running on your IOS Device

Create new Unity project
Create a new Unity project. Right click in the Project panel and select Import PackageCustom Package to import  metaioSDK Unity package:


Once package has been imported, the following changes are required:

Add a user layer

Click on Layers drop down at top-right corner of the Editor and select Edit Layers.

Add a new layer in next available User Layer, e.g. call it "metaioLayer".

Set Application Signature

For each application you need an unique signature. How to generate a signature is explained here.
After creating a signature, you could start creating your own application.  Delete Main Camera object created by default and instantiate a metaioSDK prefab by dragging and dropping it into hierarchy view of your project.

Select metaioSDK in the Hierarchy panel and then in the Inspector view set the previously generated application signature.


Important: If an invalid application signature is provided, the plugin will fail to load.

Adding tracking configuration

Create the required tracking configuration. See here for a guide.
----------------------------------------------------

Create an application signature


Creating an Application Signature is free of charge. The following steps are required:

  1. Register at the Metaio Developer Portal
  2. Add the Application Identifier (i.e. Application ID / package name) of your application. This will instantly create an according signature that corresponds to the Application ID. You will receive it via email or you can use it directly from the developer portal.
  3. Copy & paste the signature into your application for using it with the function CreateMetaioSDKIOS() or CreateMetaioSDKAndroid() (depending on the according platform). 

-----------------------------------------------


Create StreamingAssets folder in your Assets folder and copy there tracking configuration with respective patterns.
Select metaioSDK in the Hierarchy panel and then in the Inspector view select StreamingAssets in a drop down menu Select Configuration. Then you could simply drag and drop your tracking configuration file to the Inspector view.

Binding Unity game objects with tracking data

Instantiate a metaioTracker prefab by dragging and dropping it into hierarchy view of your project. Metaio Tracker instance is a reference in your Unity project to a corresponding COS in your tracking configuration file. Note that you have to set Coordinate System ID that corresponds to a valid COS in the currently set tracking data.
Once it has been done, you could attach new game objects to metaioTracker instance.

Listening for metaioSDK callbacks

The metaioSDK callbacks can be received by extending metaioSDKCallback class, e.g  QRCodeReader example.:

public class QRCodeReader : metaioCallback {    override protected void onTrackingEvent(List<TrackingValues> trackingValues)    {        foreach (TrackingValues tv in trackingValues)        {            if (tv.state.isTrackingState())            {                string[] strList = tv.additionalValues.Split(new string[] { "::" }, 2, System.StringSplitOptions.RemoveEmptyEntries);                if (strList.Length > 1)                 {                    GetComponent<QRCodeReaderGUI>().setCode(strList[1]);                    Debug.Log("QR code read:  "+strList[1]);                }            }        }    }}

The behavior can be attached to any GameObject.
Important: The metaioSDK GameObject by-default enabled base metaioSDKCallback behavior mainly for logging. This should be disabled, so that your callback receives the events.

Build and Run

Everything should be configured now, press "Build and Run" (or CTRL+B if you prefer) to run it on the device.
The default tracking configuration will track the following pattern and display the famous MetaioMan character (once it was binded in Unity as it was explained in previous step):

Change Build Settings (Android, iOS)

Go to FileBuild Settings, select Android or iOS. In the Inspector, select "Landscape Left" as default orientation for all platforms.
Click "Other Settings" in the Inspector and set Bundle Identifier. This bundle identifier will be used to verify application signature (see Set Application Signature step).

Android

For Android, change the following as minimum requirement to run metaioSDK plugin:
  • Set minimum API Level to 10 (Android 2.3.3 Gingerbread)
  • Set ARMv7 only for Device Filter
  • Set OpenGL ES 2.0 for Graphics Level (optional)

iOS: Adding the library and necessary frameworks

After exporting the Unity project to Xcode, the Unity Plugin has to be added to the project, as well as some external frameworks. Also, please select ARMv7 only in the iOS project settings.
To do that, just drag the metaiosdk library right into Xcode:


After this is done, please add the following frameworks to the project:
  • libc++.dylib
  • libxml2.2.dylib
  • Security.framework
  • CoreImage.framework (SDK 5.5 and newer)

To enable GPS support you have to add these keys to the projects Info.plist:
  • NSLocationWhenInUseUsageDescription (for iOS8)
  • NSLocationUsageDescription (for ios6 and ios7)

If you push 'Run' the application will then link successfully and run on your device.


This video is a bit dated but has the core of the work flow-
***we are not working with play maker

No comments:

Post a Comment