#if XAPI_REGISTRY_EXISTS using System; using System.ComponentModel; using OmiLAXR.Context; using OmiLAXR.xAPI.Composers; using UnityEngine; using UnityEngine.SceneManagement; namespace OmiLAXR.xAPI.Hooks { [AddComponentMenu("OmiLAXR / 5) Hooks / Scenario Context Hook (xAPI)")] [Description("Adds language by , platform by , fps by , registration by and active scene, game and game version to the context of all statements.")] public class ScenarioContextHook : xApiHook { protected override xApiStatement AfterCompose(xApiStatement statement) { if (ScenarioLanguage.Instance) { var language = ScenarioLanguage.Instance.language; var langCode = language.ToString(); // ensure it has not "_" prefix statement.WithLanguage(langCode[0] == '_' ? langCode.Substring(1) : langCode); } if (PlatformInformation.Instance) { var composerName = statement.GetComposer().GetType().Name; // Add platform information var platform = PlatformInformation.Instance.GetPlatformString("xAPI", "2.0.19", composerName); statement.WithPlatform(platform); } if (FpsMonitor.Instance && FpsMonitor.Instance.enabled) { statement.WithContext(xapi.systemControl.extensions.context.fps(FpsMonitor.Instance.CurrentFPS)); } if (Registration.Instance && Registration.Instance.enabled) { statement.WithRegistration(new Guid(Registration.Instance.uuid)); } // add application name and version var activeScene = SceneManager.GetActiveScene(); // Get the name of the active scene var sceneName = activeScene.name; statement.WithContext(xapi.seriousGames.extensions.context.game(Application.productName)); statement.WithContext(xapi.generic.extensions.context .learningScenario(sceneName) .version(Application.version)); return statement; } } } #endif