2.9.16
Coherent GT Unity3D Guide
A modern user interface library for games
Getting Started

In this guide

  • How to add Coherent GT to your Unity3D Project
  • What can you find in the Coherent GT package
  • Add a Coherent GT view to your scene
  • Distributing games with Coherent GT

What do you need before we start

Before starting development with Coherent GT, make sure you have the following:

  1. Unity3D 5.4 or higher
  2. Coherent GT unitypackage
  3. License key, if you're using Coherent GT Pro version.

Add CoherentGT in your Unity3D project

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 Coherent GT package.
  3. Click Open and a Unity3D dialog with all files of the package files listed should open.
  4. Click Import.

If you're using a Coherent GT Pro package, there's an additional step - you should navigate to Assets\Standard Assets\Detail and copy your license key in the LicenseGT.cs file.

What's there in the Coherent GT package

Here is the structure of the Coherent GT package explained briefly, assuming Assets is the root folder:

  • CoherentUIGT - this folder contains useful resources.
    • Documentation - folder containing the documentation.
    • Editor - folder containing scripts used by the Unity3D Editor, the binaries for the Coherent Editor and for the debugger.
    • Resources - contains the shader files used to render CoherentUIGTViews in Unity3D.
    • Samples - folder containing samples with Coherent GT.
    • CoherentEditor.zip - archived standalone version of Coherent Editor.
    • Debugger.zip - archived Coherent GT debugger binaries.
    • Inspector.zip - archived files needed for the Coherent GT debugger.
    • JavaScriptBinding.zip - contains the JavaScript engine used by Coherent GT for triggering events in JavaScript.
  • Plugins - the Coherent GT library files and their dependencies (split into two sub folders containing the files needed for x86 and x86_64 builds respectively).
  • Standard Assets - contains the Coherent GT components that you'll need for UI development.
    • CoherentUIGTView.cs - component used for displaying web pages.
    • CoherentUIGTSystem.cs- component used to initialize and manage the UI.
    • CoherentUIGTLiveGameView.cs - component used for easy creation of live views.
    • CoherentUIGTLocalization.cs - component used for localization of web pages.
    • Detail - scripts used by the above components, you do not need to add them directly to your scene.
  • WebPlayerTemplates/uiresources - contains HTML, CSS and JavaScript UI resources for the samples.
  • WebPlayerTemplates/inspector - contains the files needed for the Coherent GT debugger.
  • WebPlayerTemplates/editor - contains the files needed for the Coherent Editor.
  • WebPlayerTemplates/DX11Shaders - contains the shaders that Coherent GT uses when rendering the web page with DirectX11 and DirectX9.
  • WebPlayerTemplates/OpenGLShaders - contains the shaders that Coherent GT uses when rendering the web page with OpenGL.

Add CoherentGTView to your scene

You can add views both to Camera objects and to regular game objects in world. The first type, are suitable for HUDs and menus, while the latter can be used for interaction between the player and the game.

Let's have a simple HTML page, HelloHTML.html

Place it in your UI Resources folder. By default, this is the *Assets* folder, unless you change it from Coherent GT -> Setup -> Select UI Resources folder.

Then, choose a GameObject in the scene, where the page should be placed. Let's say we want to display it instead of HUD - in this case click the MainCamera object in the scene and then Add Component, afterwards choose Coherent GT 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.

Distributing games with Coherent GT

CoherentUIGTDevelopment.dll is the library where the debugger is implemented. It is copied only when you build with Development Build option. If the library is missing, the debugging functionality is disabled. You can also copy it manually, to enable the debugger. Just make sure that you specified a valid port in the system settings.