Integrating a Unity component into Lectora

sulaimaanrb
Community Member Posts: 7 ☆ Roadie ☆
Hi,
I am investigating the integration of an interactive 3D Unity component into Lectora.
So far I have been able to embedded the component using the External HTML Object. My next step is to establish the communication channels between the component and Lectora (using variables to pass values back and forth, event triggers etc.).
Has anyone attempted a similar integration? Any advice/suggestions will be appreciated
I am investigating the integration of an interactive 3D Unity component into Lectora.
So far I have been able to embedded the component using the External HTML Object. My next step is to establish the communication channels between the component and Lectora (using variables to pass values back and forth, event triggers etc.).
Has anyone attempted a similar integration? Any advice/suggestions will be appreciated
Comments
-
Yes, and it's really easy. So you have your Unity stuff running in an iframe on a webpage. What you need is to let it talk to the parent page (Lectora course) and use JS to set variable values.
Part 1. Talking to the parent page.
Method A. If both the course and the Unity object are on the same host, you use ExternalCalls in Unity (http://docs.unity3d.com/ScriptReference/Application.ExternalCall.html) to run JS commands in the HTML page, such as window.parent.VarMyScore1.set('99'). Nothing has to be done in Lectora.
Method B. If the Unity object is somewhere else, this won't work. So you need to use postMessage() to communicate. In Unity, it's pretty much the same, you use external calls to execute JS that issues postMessage calls. But also you will need to run a simple script in Lectora ( window.addEventListener('message', function() {}) ) to listen to the messages and act on them.
Part 2. Setting Lectora variables via JS.
There's a ton of information on these forums, but here's a short overview:
- set a variable - VarMyvariablename.set("value")
- get value from a variable - VarMyvariablename.value()
- go to next page in title - trivNextPage(); trivPrevPage();
- execute a Lectora action - action1234();
- hide/show an object - image1234.actionHide(); image1234.actionShow() -
Categories
- 35.9K All Categories
- 109 ✫ Announcements
- 33.1K Lectora®
- 31.1K Lectora Discussions
- 29K Lectora Desktop
- 2K Lectora Online
- 2K Lectora Feature Requests
- 71 Lectora User Groups
- 36 Lectora Accessibility User Group (LAUG)
- 25 ELB Learning Content
- 25 ELB Learning Content Discussions
- 329 CenarioVR®
- 196 CenarioVR Discussions
- 133 CenarioVR Feature Requests
- 42 Rockstar Learning Platform®
- 39 Rockstar Learning Platform Discussions
- 108 CourseMill®
- 108 CourseMill Discussions
- 47 ReviewLink®
- 47 ReviewLink Discussions
- 7 The Training Arcade®
- 7 The Training Arcade Discussions
- 936 All Things eLearning
- 37 eLearning Development
- 546 Learning Management System (LMS) Integration
- 333 Web Accessibility
- 1.2K ♪ The Green Room
- 9 Additional Learning Products