1.4.2.0
Gameface
Quick Start Guide

This guide describes the features of the Gameface integration in Unity3D. A basic understanding of the Unity3D engine, as well as HTML/JavaScript is assumed.

Brief overview of Gameface

Gameface 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 CohtmlUISystem 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 and so on.

Installation

Gameface for Unity3D is distributed in a unitypackage file. You can import this package in your project by either double-clicking on it, or by importing it through Unity in the Project window.

First, open your project in Unity3D Editor, then:

  1. From the menu bar choose Assets -> Import package -> Custom package
  2. Navigate in the file chooser dialog to the folder with your Gameface package.
  3. Click Open and a Unity3D dialog with all files of the package files listed should open.
  4. Click Import.
Note
Currently the default Scripting Runtime Version for Unity3D is .NET 4.x , but Gameface only supports .NET 3.5. In order to change the default version you should go to Edit > Project Settings, then select the Player category and change the Configuration to .NET 3.5. More info here.

The trial version includes a 30 day trial license key. After the key expires you won't be able to initialize Gameface and an error message will be logged in the console.

The pro version requires entering your license key first. The license key is located at Standard Assets/Cohtml/Detail/License.cs. You should've received this file already prefilled with your license key when you bought the pro version. Replacing the existing empty License.cs file from the package with the provided one will activate Gameface.

Note
The trial and pro packages contain different libraries. When upgrading to pro from trial, you should reimport the pro package and replace the libraries.

Package contents and structure

The package has the following structure:

  • Gizmos/Cohtml - icons only for Unity Editor integration.
  • Cohtml - contains samples and documentation.
  • Plugins - contains the Cohtml libraries. These are automatically copied when building.
  • Standard Assets/Cohtml - contains the Gameface integration classes. You'll find a Detail folder inside which contains classes that are internal for the implementation and are used by the "public" classes. The interface you should be using is outside the Detail folder:
    • CohtmlView.cs - component used for displaying html pages.
    • CohtmlUISystem.cs- component used to initialize and manage the UI.
  • StreamingAssets/Cohtml/UIResources - contains the UI resources for Gameface. These are automatically copied when building.
Note
If you want to uninstall the package you should remove the folders listed above. Exception is the Plugins folder when you have other plugins there.

[Planned] Uninstall option in the Gameface menu

Add Gameface view to your scene

In Gameface there are two types of views - Screen and World views, the first is used for HUDs and menus, while the latter can be used for in-game UI (interactions between the player and the game). Let's start by creating and displaying a simple HTML page - call it HelloHTML.html

Create an HTML file and place it in the UIResources folder (By default, this is the Assets/Streaming Assets/Cohtml folder.). The page will be displayed instead of a HUD, so click on the MainCamera (it will be the GameObject on which the html will be attached), open Gameface (in the main menu) and choose Add Screen View. Go to the Page property of the view and set the relative URL of the HelloHTML page here, for example: coui://uiresources/HelloHTML.html. Click Play and you'll see the result.

Warning
If you have a space in the name of your project, this could forestall the HTML from loading.