Spaces SDK

Updating Tango

To update tango you need to follow two steps:

  • Remove the following folders from your Unity project folder:
  • TangoSDK
  • TangoPrefabs
  • Google-Unity
  • Plugins/Android
  • Reimport the OnirixSpaces unitypackage. More info...

Use guide

  • Crate a new empty unity project.
  • Download the last version of Onirix Spaces SDK.
  • Import the downloaded unitypackage into unity.
  • Create a new script and load your space using the following code:
    OnirixSceneLoader loader = new OnirixSceneLoader();
    loader.SetDelegate(this);
    loader.LoadSpaceScene("SPACE_OID", "EMAIL", "PASSWORD");
  • Go to File → Save scene as... and save the scene in your project root folder.
  • Go to File → Build Settings, select Android and go to Player Settings. In this windows you have to fill the field Other Settings → Package Name with three words separated by ".".

OnirixCore

The OnirixCore module provides the base functionality you can use to make your custom Space applications.

OnirixRestService

This class has several methods to communicate with the OnirixStudio API easily:

Name Description
Login(string email, string password, Action<AuthData, string> onResponse)  Logs in OnirixStudio with the given email and password. When finished, calls the onResponse action. If the login was successful, the action contains the received authentication token. If there was an error, the action contains a string with the error description.
GetAssetData(string assetOid, AuthData authData, Action<Asset, string> onResponse)  Gets data about an asset with the given oid, and using the authentication token. When finished, calls the onResponse action. If the asset data was obtained successfully, the action contains the received asset. If there was an error, the action contains a string with the error description.
GetProjects(AuthData authData, Action<Project[], string> onResponse) Gets the projects of the user authenticated by the given authData. When finished, calls the onResponse action. If the projects were retrieved successfully , the action contains the list of projects. If there was an error, the action contains a string with the error description.
GetSpaces(string projectOid, AuthData authData, Action<Space[], string> onResponse) Gets the list of spaces contained in the project with the given projectOid, of the user authenticated with authData. When finished, calls the onResponse action. If the spaces were retrieved successfully , the action contains the list of spaces. If there was an error, the action contains a string with the error description.
GetSpace(string spaceOid, AuthData authData, Action<Space[], string> onResponse) Gets a single space with the given spaceOid of the user authenticated with authData. When finished, calls the onResponse action. If the space was retrieved successfully , the action will contain it. If there was an error, the action contains a string with the error description.
GetDatasheet(string datasheetOid, AuthData auth, Action<Datasheet, string> onResponse)  Gets the datasheet with the given datasheetOid of the user authenticated with auth. When finished, calls the onResponse action. If the datasheet was retrieved successfully , the action will contain it. If there was an error, the action contains a string with the error description.
GetSpaceElementDatasheets(string spaceOid, string elementOid, AuthData authData, Action<List, string> onResponse)  Gets the datasheets associated with the element with the given elementOid, which is in the space with the given spaceOid. When finished, calls the onResponse action. If the datasheets were retrieved successfully , the action contains the list of datasheets. If there was an error, the action contains a string with the error description.

OnirixAssetLoader

This class contains the functionality to load space projects into a Unity scene. It provides the following methods:

Name Description
LoadSpace(Space space, AuthData auth, Action onSpaceLoaded) Loads the space given into the UnityScene, using the authentication token. When the space is loaded, the onSpaceLoaded action is called, which contains the space GameObject.
SetObjectVisibility(GameObject gameObject, bool visible) Sets the visibility of the given GameObject.
ToggleObjectVisibility(GameObject gameObject) Toggles the visibility of the given GameObject.

OptionsMenuManager

This class gives an easy way to create a options menu for each space element, where you can delete, play the animation or view the datasheet of the element you want. It provides the following methods:

Name Description
ShowOptionsMenuFor(GameObject element, string containerOid, AuthData authData, ProjectType type, Action onAnimationButtonPressed, Action onDatasheetButtonPressed, Action onRemoveElementPressed) This method shows the options menu for the given space element in the Unity scene. It receives the containerOid of the space, the authentication token of the user and the type of project (in this case Spaces). When the animation button is pressed the gameobject will be animated and the onAnimationButtonPressed action will be called, which receives a boolean indicating if the element is currently animated or not. When the view datasheet button is pressed, the onDatasheetButtonPressed action is called, which receives the datasheet of the element. Finally, if the remove element button is pressed, the element will be removed and the onRemoveElementPressed action will be called.
ShowPanel()  Shows the options menu.
HidePanel() Hides the options menu.

If you want to use the OptionsMenuManager in your application you need to add the script component to the scene:

The component has the following serialized fields:

  • Options Menu Panel: Panel to show.
  • View Datasheet Button: Button object that will be pressed to view the datasheet of the space element.
  • Toggle Animation Button: Button object that will be pressed to toggle the animation state of the space element.
  • Animation image: Image object that contains the animation icon.
  • Play animation image: Icon to show when the space element is not being animated.
  • Stop animation image: Icon to show when the space element is being animated.
  • Remove Element Button: Button object that will be pressed to remove the element from the scene.
  • Default components for this script are provided in the prefabs folder.

OnirixEventManager

This class takes care of handling the events that you can set up in OnirixStudio. To use it, you need to add the script component to your Unity scene, and call the following method in you application:

OnirixEventManager.instance.StartSpaceEvents();
// load the events of a specific space
OnirixEventManager.instance.Load(space);

DatasheetManager

This class gives an easy way to show a default datasheet of a space element. It provides the following methods:

Name Description
ShowElementDatasheet(Datasheet datasheet, AuthData auth, string containerType, string containerOid) Shows the given datasheet, using the provided auth token.
ResetDatasheetContent()  Removes all the previous information stored in the datasheet.
SetOnCloseButtonListener(UnityAction action) Calls the given action when the close button of the datasheet panel is pressed.

As with the OptionsMenuManager, you can make use of this class after you add its script as a component in the Unity scene:

These are the serialized fields you can set up:

  • Datasheet Panel: Panel used to show the datasheet content.
  • Datasheet Panel Close Button: Button object that will close the datasheet panel when pressed.
  • Datasheet Title: Text object that will contain the datasheet title.
  • Datasheet Image: Image object that will contain the datasheet image.
  • Datasheet description: Text object that will contain the datasheet description.

 OnirixSceneLoader

This class provides some utility methods to load your spaces into the unity scene. To use the class you need to implement the OnirixSceneLoaderInterface and write the following three lines of code:

OnirixSceneLoader loader = new OnirixSceneLoader();
loader.SetDelegate(this);
loader.LoadSpaceScene("SPACE_OID", "EMAIL", "PASSWORD");
The OnirixSceneLoader class provides the following methods: Name Description
LoadSpaceScene(String spaceOid, String email, String password) Loads the space with oid "spaceOid" in the Unity scene, using the given email and password.
LoadSpaceScene(String spaceOid, AuthData auth) Loads the space with oid "spaceOid" in the Unity scene using the token provided.

OnirixSceneLoaderInterface

In order to implement the OnirixSceneLoaderInterface you need to implement the following methods:

Name Description
OnSpaceSceneLoaded(Space space, GameObject spaceGameObject) This method is called when the space was loaded into the scene correctly. It returns the space object, and the GameObject loaded into the scene.
OnLoadError(String error) This method is called when there was an error loading the space onto the scene.

OnirixTangoSDK

OnirixTangoManager

The OnirixTangoSDK provides different methods to establish a route to one space element:

Name Description
LoadRoute(Element element, Space space) Creates a route that goes to the given space element, using the default route configuration.
LoadRoute(Element destination, Space space, RouteConfig config) Creates a route that goes to the given space element, using the given custom route configuration.
LoadRoute(SpaceRouteNode destination, Space space)  Creates a route that goes to the given space route node, using the default route configuration.
LoadRoute(SpaceRouteNodes destination, Space space, RouteConfig config) Creates a route that goes to the given space route node, using the given custom route configuration.

ITangoManagerEventListener

The ITangoManagerEventListener interface can be implemented to receive notifications for some of the events that can occur in your space application. If you wan to receive these notifications, you have to implement the following methods:

Name Description
OnSpaceLoaded(Space space) This method is called when a new space is loaded. It receives as parameter the loaded space object.
OnLoadingStart() This method is called when the loading of a space is started.
OnLoadingEnd() This method is called when the loading of a space has ended.
OnRelocalizationNeeded() This method is called when Tango needs to relocalize the scene.
OnRelocalizationDone() This method is called when Tango has relocalized the scene.

 RouteConfig

This class can be use to set up different route designs for your custom application. It follows the builder pattern, so to create a new route configuration you have to use the RouteConfig.Builder class, as shown below:

RouteConfigBuilder builder = RouteConfigBuilder();
Font myCustomFont = Resources.GetBuiltinResource(typeof (Font), "Arial.ttf") as Font;
RouteConfig config = builder.SetRoadColor(new Color(0.9, 0.5, 0.32, 0.42).SetTextFont(myCustomFont).Build();

The RouteConfig builder provides the following methods:

| Name | Description | | ---- | ----------- | |RouteConfig Build() | Returns the RouteConfig object with the parameters specified in the builder object.| |Builder SetRoadColor(Color color) | Sets the color of the road between nodes in the route to the specified color.| |Builder SetWaypointColor(Color color) | Sets the color of the route waypoint to the specified color.| |Builder SetDestinationColor(Color color) | Sets the color of the destination node in the route to the specified color.| |Builder SetTextFont(Font font) | Sets the font used to display the name of the nodes in the route.|