Register for our next webinar, 5 Keys to Unlock Storytelling in Your eLearning, where you'll learn how to unlock the magic of storytelling in your eLearning development to increase learner engagement and retention! Join Andrew Townsend, our Campaign Marketing Manager, on Thursday, December 3, 2020 at 11:00 AM MDT.

Be The First On Your Block to Rock Lectora® 21!


Apply for exclusive early access to the latest version of Lectora® Desktop v21. Seating is limited so apply now!

In need of help with your eLearning? Feel free to ask a question of the community! You can also visit our Knowledge Base or, if you're in need of immediate assistance, submit a case to our Customer Success team.

Integrating a Unity component into Lectora

sulaimaanrbsulaimaanrb Community Member Posts: 7
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

Comments

  • ssnegssneg Community Member Posts: 1,466
    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()
  • sulaimaanrbsulaimaanrb Community Member Posts: 7
    Awesome, thanks alot.



    Will give it a try and let you know what the outcome is. ;)
Sign In or Register to comment.

So You Wanna Be An eLearning ROCKSTAR?

We're all fans of eLearning here! Want to become an eLearning ROCKSTAR? Just click on one of the buttons below to start your rocking journey!

Be The First On Your Block to Rock Lectora® 21!


Apply for exclusive early access to the latest version of Lectora® Desktop v21. Seating is limited so apply now!