Wiki
Clone wikiSAGE2 / SAGE2 Unity Applications
Last revision: 11 November 2017
Introduction
Unity WebGL applications can be displayed in SAGE2 similar to how native SAGE2 applications - by dragging and dropping a zipped application folder on the SAGE2 web UI. As Unity applications are displayed as locally hosted WebViews, the display client must be using Electron. WebGL builds from Unity 5.4.2 up to Unity 2017.1.1 have been tested.
Unity applications will be listed under the Media Browser along with the other SAGE2 applications.
An example SAGE2 Unity app is available on the SAGE2 App Repository as 'Unity Interaction Test' under 'Examples for Developers'
The Unity project source code for this example is also available at: https://bitbucket.org/sage2/sage2_unity
Unity Build Configuration
Before a Unity WebGL application is built for use in SAGE2, under Build Settings/Player Settings/Settings for WebGL/Resolution and Presentation, set the WebGL Template to 'Minimal.' This will format the application so it can be displayed as a full screen, window-scalable application.
Preparing to install on SAGE2
Native SAGE2 applications require an instructions.json file which specifies the size of the window, custom icons, description, author, and more. For Unity applications, to have an instructions.json file is recommended, but not required. If SAGE2 detects a Unity WebGL application without an instructions.json, it will be auto generated.
Example instructions.json
{ "main_script":"UnityLoader.js", "icon":"unity.png", "width":960, "height":600, "resize":"free", "animation":true, "dependencies":[], "load":{ }, "title":"SAGE2-Unity-Application", "version":"1.0.0", "description":"Unity WebGL build loaded as a Webview", "keywords":["sage2","unity3d","webview"], "author":"Name <email@mail.com>", "license":"SAGE2-Software-License" }
- [Application folder (Same name as zip file)]
- Build folder
- [Unity data files]
- UnityLoader.js
- index.html
- Build folder
Interaction
Some keys such as Escape, Middle Mouse Button, and Shift-QuestionMark are used by SAGE2 and may conflict with interaction. Input mapping in the current implementation of the SAGE2-Unity module depends on what interaction device is used (ex: SAGEPointer vs direct mouse input).
SAGEPointer
Interaction | Support Status | Notes |
---|---|---|
Input.mousePosition | Supported | |
Input.keycode (Mouse) | Supported | Mouse0 (Left), Mouse1 (Right), Mouse2 (Middle) all working. Note Mouse2 is also used to switch interaction mode. |
Input.keycode (Key) | Partial Support | No lowercase letters*. Some non-alpha numeric keys missing: F-keys, Home, End, Insert, Delete, Minus, Backquote, LeftBracket, Semicolon, Comma, Period, Quote |
Input.scrollWheelDelta | Supported | |
InputManager | Partial Support | "Horizontal" and "Vertical" partially working*, "Fire" 1, 2, 3, "Jump", and "Submit" fully working. |
Canvas Interaction (Buttons, Slider, Toggle) | Supported | |
Canvas Text Field | Partial Support | Keys not supported by Input.keycode work, except no backspace or lower case letters*. |
Gamepads | Not Supported | Future feature |
Interacting Directly on Display Client
Interaction | Support Status | Notes |
---|---|---|
Input.mousePosition | Supported | |
Input.keycode (Mouse) | Supported | Mouse0 (Left), Mouse1 (Right), Mouse2 (Middle) all working. Note Mouse2 is also used to switch interaction mode. |
Input.keycode (Key) | Partial Support | No lowercase letters*. |
Input.scrollWheelDelta | Supported | |
InputManager | Supported | No lowercase letters*, backspace supported |
Canvas Interaction (Buttons, Slider, Toggle) | Supported | |
Canvas Text Field | Supported | No lowercase letters*, backspace supported |
Gamepads | Supported | via native Gamepad API for HTML5 |
- All letter keys are sent to Unity applications as uppercase to allow InputManager Vertical/Horizontal axis to function though the SAGEPointer
Updated