Coherent UI for Unity3D  2.5.3
A modern user interface library for games
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Introduction

This guide describes the features of the Coherent UI integration in Unity3D. A basic understanding of the Unity3D engine, as well as HTML/JavaScript is assumed. Having basic knowledge of the C++ API and design of Coherent UI may be advantageous. To familiarize yourself with Coherent UI, please read the main documentation file or visit Coherent UI website.

Brief overview of Coherent UI

Coherent UI is a modern user interface middleware solution that allows you to integrate HTML pages built with CSS and JavaScript in your game. The communication between your game and the HTML engine is done through the UI System component. Each HTML page is called a View. The View component allows you to perform operations on the page, such as resizing, navigating to a different URL, sending input events, executing custom JavaScript code and so on. You can create a view through the CreateView method of the UI System component. It requires you to supply some initialization parameters, such as width, height, initial URL, etc. It also requires an instance of a View Listener. Coherent UI is highly asynchronous by design, meaning that when you change the URL of a View, for example, the function will return immediately and you will receive a notification when the URL has actually changed. The ViewListener is the class that receives such notifications for a specific view - when the URL was changed, the page you're trying to open requires authentication details, etc.

Differences between Desktop and Mobile version

Coherent UI can be divided conceptually in two libraries - Coherent UI Desktop (for Windows & MacOSX) and Coherent UI Mobile (for iOS and Android). Due to platform limitations the two have a different subset of features. Namely the Mobile version has some limitations while the Desktop version is fully featured.

Warning
The current version of Coherent UI for Android has known issues when using the software keyboard alongside with Unity's one. Keyboards other than the default may not work as expected (e.g. Swype).

Mobile limitations on Coherent UI Mobile include:

  • You are only able to create 2D views on-top of your game for HUDs or in-game browsers. Views splatted on 3D surfaces in the game world are not supported due to platform limitations on iOS and Android.
  • Input management must be implemented through minor changes in the HTML & JS and is not pixel perfect but HTML element-based.
  • Bound objects are currently missing from the binding
  • No on-demand views and frame-rate control
  • When writing scripts, the IDE's autocompletion will use the API for the Desktop version. There are a few methods that are available only for Desktop and others only for Mobile, so you won't see the mobile ones in your code editor. The classes for the mobile version are named the same as the desktop version but they're in a different namespace, Coherent.UI.Mobile. You can inspect the objects in that namespace to check the availability of the method you're looking for. In MonoDevelop you can inspect an object by using the "Go to declaration (F12)" feature.

Other that that the API has been kept 100% compatible between the Desktop & Mobile versions. The Core binding, Resource management and View management are the same. Coherent UI Mobile supports both device builds and simulator ones.