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

The Unity API is an extension of the normal .Net API, and it is contained in the main API Reference documentation.

CoherentUISystem properties

  • Proxy - Enables proxy support by autodetecting the system settings. This detection is usually very slow and this setting should be enabled only when the user is behind a proxy and you're accessing the Internet.
  • Cookies - Enables support for cookies.
  • Cookies file - A file that will be used for reading and writing cookies when they are enabled.
  • Cache path - Path for saving cached data. Leave null for in-memory caching only.
  • Local storage path - Path for saving HTML5 page local storage data. Leave null to forbid local storage.
  • Disable fullscreen plugins - Disables fullscreen mode for all plugins (e.g. Flash, Silverlight, etc.)
  • Disable web security - Disable same origin policy. Use with caution.
  • Debugger port - The port that will be opened for the debugger to connect and debug your interface. A value of -1 means disabled.

The CoherentUISystem component also provides a static factory function object (FileHandlerFactoryFunc) that the user can customize in order to make use of her own FileHandler. See the Custom file handler section for a detailed explanation.

CoherentUIView properties

General section:

  • URL - Indicates the URL that will be initially loaded.
  • Width - The width of the Coherent UI View.
  • Height - The height of the Coherent UI View.
  • Transparent - Defines if the View supports transparency.

Rendering section:

  • Draw order - Defines whether the View is drawn before or after the post-effects. Available for Views attached to cameras.
  • Flip Y - Flips the drawn image vertically.
  • Texture Filtering - The filtering mode used for rendering the views. The two available modes are Point Filtering and Linear Filtering. (View Filters - Desktop only )
  • Software only rendering - The View will be rendered without hardware acceleration.
  • Match camera size - The View will be automatically resized to always match the size of the camera.

Advanced rendering section:

  • On Demand - Provides perfect synchronization of the game frames and Coherent UI frames. Use this when you need to synchronize the game and the interface, e.g. when displaying name tags over the players. Using standard views may introduce a delay of a few frames.

Note: The synchronization is done in Unity's LateUpdate() method, so updating of objects that have UI elements should be done in regular Update(), or updates of components should be re-arranged (via Script Execution Order Settings) so the update of CoherentUIView is last.

  • Timer override - The UI uses the in-game timer. (requires On-demand)
  • Max. frame-rate - Sets the maximum framerate for the View. The view will never exceed this framerate.
  • Always on top - Indicates whether this value is z-buffer independent. If it is set to true, the view is rendered on top of everything.
  • Compensate gamma - The View will have gamma corrected when linear color space is used. Whether you should use this property or not depends on the scene you are making - are there any additional cameras, what kind of rendering path they use, etc. Generally, this property comes handy when you use linear color space and the view is attached to a camera with deferred lighting or if your main camera uses deferred lighting and the camera with the view does not.

Input section:

  • Smart input - Available for transparent Views. Enables support for queries whether the cursor is over a transparent pixel. A transparent pixel is considered one that has an alpha value below or equal to the click-through alpha threshold.
  • Smart input alpha - A value in the range [0-1]. inclusive that determines whether a pixel is transparent; A pixel is transparent if its alpha value is below or equal to the threshold.
  • Lockable focus - When enabled, the View takes the input focus when clicked and releases it when you click outside the View. See Click to focus Views
  • Enable IME - When enabled, this view will have Input Method Editor enabled for langugages that have more complex input like Chinese.

Scripting section:

  • Pre-load script - The script will be executed before any other code in the UI View.
  • Auto UI messages - When enabled, any event triggered in JavaScript on the engine object is forwarded to the game object containing the View.
  • Enable [CoherentMethodAttribute] - Enables the usage of the [Coherent Method attribute]. (CoherentMethod attribute for .NET scripts )
  • Show JS dialogs - Automatically handle JavaScript messages and authentication requests. If enabled, a visual dialog will be shown; otherwise it's up to the programmer to make the appropriate response. If you do not respond to the message, the page will block until you do. Examine ViewListener.cs and CoherentDialog.cs for a sample reply logic.

CoherentUILiveGameView properties

General section:

  • Name - This is the string used as an identifier for the Live Game View. In the UI JavaScript code this string can be used to apply specific logic to only certain live views.
  • Width - The Width of the Live Game View. The ImageData object created in the UI JavaScript DOM will have this width.
  • Height - The Height of the Live Game View. The ImageData object created in the UI JavaScript DOM will have this height.
  • Source Camera - The camera that will provide the images for the Live Game View. Everything rendered by this camera will be sent in the UI JavaScript universe and automatically updated every frame. If you omit a Source Camera than the source texture will be used.
  • Source Texture - A texture to be used as source for the Live Game View images. If both a camera and a texture are specified - than the first frame in the live view will use the texture but all others will be provided by the Camera. If you omit specifing a Source Camera than only the texture will be used. If you change the content of the source texture and want to update the Live View linked to it you can do it by calling the "UpdateFromCurrentTexture" method of the Live Game View component.
  • Read alpha - Specifies if to read the alpha value drawn by the Source Camera.