TIBCO Cloud™ LiveApps - Unity3D Package

This package allows you to connect a Unity3D Application to TIBCO Cloud™ LiveApps.

The Implementation leverages TIBCO Cloud™ and TIBCO Cloud™ LiveApp REST APIs. It is working in Unity3D Editor, Android ARCore, and on Microsoft Hololens (UWP).

Once connected to an existing LiveApps business application, the Unity app can retrieve cases information including attached documents and display this information in a 3D scene.

It is also possible to create new case instances from a Unity3D application and attach documents to the cases.

The Package contains a sample Scene that demonstrates how to create cases, attach documents, retrieve a list of cases and display the received data as information cards.

Build a sample LiveApps application

In order to experiment this Unity package, you need an existing TIBCO Cloud™ LiveApps appplication.

Trial Account

If you don’t have a TIBCO Cloud™ account with LiveApps capability you may register for your own TIBCO Cloud™ LiveApps trial account on this Sign-up Form. Then, obtain your personal ID and Authorization key under ‘Authentication Keys’ Settings Tab, beside the Subscription ‘Status’ in you TIBCO Cloud™ account.

“Info Card” business application

The following video shows you how to create a LiveApps application in 5 minutes to handle “Info Cards”. The LiveApps Unity package contains a sample using this application. The “Info Card” let you create flash ‘cards’ about any topic by entering a category, a name, a description and by uploading a picture associated with the card. In our example we are creating ‘cards’ about animals. The Unity sample Scene connect to your LiveApps account, retrieves the cards and displays the information including the attached picture.

How to use the package

Import into Unity3D

Just created a new Unity Project, configure it for your target, and import the ready to use Package from the Packages Folder

Use the Sample scene

The package contains a test scene at TIBCOLabs > LiveApps > Sample > BoardScene

The Scene contains a MainController Object. In the MainController, you can update the Connection property prefix (default is “liveapps”). It is used to read properties in the credential file :

the credentials must be declared in a file named “TIBCO-credentials.txt” and placed in a Resources folder. For example in TIBCOLabs > Utils > Resources.

The file must contain [prefix].username, [prefix].password and [prefix].clientid with the values from your TIBCO Cloud™ Subscription Details

The package contains a sample credential file for you to copy.

On the script BoardViewController.cs attached to the main controller check that “LiveApps App Name” matches the name of the LiveApps application you have created. The default is “Info Card”.

When playing the BoardScene in unity Editor, you should see the data retrieved from LiveApps application in the form of cards :

alt-text
TIBCO LiveApps cases in Unity Editor

The sample application is creating a Card for “ant” if the card does not exist so you can see how to create LiveApps cases and attach documents.

API details

Authentication

This Implementation supports two ways of Authentication to TIBCO Cloud.

Both can be defined via a resource file in Unity ‘Resources’ Folder, called ‘TIBCO-credentials.txt’.

liveapps.user = someone@domain.com
liveapps.method = oauth || password
liveapps.region = US || EU || EA

# via 'oauth'

liveapps.oauth = CIC~...<your CIC oAuth Key>

# via 'password'

liveapps.password = <your CIC password>
liveapps.clientID = Jsf95ioVIq...<your CIC Org Client ID>...73iI

We stored a sample of it into ‘Assets\TIBCOLabs\LiveApps\Resources’ folder.

connection to LiveApps

Just add TIBCOLiveAppsConnector script in your scene and set the credentials to be connected to your LiveApps instance.

Create a controller script by extending “TIBCOLiveAppsHandler”. Have a look at the sample BoardViewController.

ConnectionReady is invoke when the connector successfully connects to LiveApps.

The connector object has the following public methods :

read LiveApps cases

public void GetAllCases(string applicationName, string stateName, string searchString, bool getArtifacts = false, Action<CaseInfoWrapper> onComplete=null)

To get a list all cases in a LiveApps application,

  • in the given state if state is not null.
  • matching the searchString if not null

Use either a state or a searchString but not both.

retrieveDocuments : true to get artifacts ie documents and images associated with the cases.

The implementation is asynchronous and will call the onComplete callback on completion. The callback has a parameter of type CaseInfoWrapper holding the cases.

You may check the structures in TIBCOLiveAppsConnector.cs

To Manipulate the case data easily create a class representing the LiveApps case information. in our example we are using :

    public class ElementData
      {
        public string Name;
        public string Description;
        public UnityEngine.Texture2D texture;
      }

We have the 2 fields from LiveApps application and we have added a texture to store the first document of type image.

In the OnCase callback you can create instances from the CaseInfoWrapper data :

    foreach (CaseInfo item in data.items) {
      ElementData card = JsonUtility.FromJson<ElementData>(item.casedata);
      ...

create a LiveApps case

public void CreateCase(string applicationName, System.Object data, string creatorName = null, Action<ActionResponse> onComplete = null)

See the sample on how to create the data object.

If the creatorName is null, the connector will use the first creator.

The onComplete callback has an ActionResponse parameter.

attach a document to an existing case instance

public void AttachDocument(string caseReference, string documentName, string description, byte[] data, string mimeType,Action onComplete=null)

Target Devices

Tested with Microsoft Hololens 1 & 2, Android Smartphones and Unity Editor on Windows 10.

Used Versions

  • Unity (2019.4.10f1)
  • Unity AR Foundations (3.1.0)
  • Unity AR Subsystem (3.1.0)
  • Unity ARCore XR Plugin (3.1.0)
  • Android 10
  • Google Pixel XL
  • Microsoft Hololens V2

Content

git repositories :


Last modified June 15, 2021: update with CIC oauth details (910758c7)