//this happens AFTER tracking scene is set //all registered dynamic objects will send data in the new scene //each dynamic left behind in the old scene should call 'removedynamic' to remove itself from ActiveDynamicObjects list static void OnSceneLoaded(Scene scene, LoadSceneMode mode, bool didChangeSceneId) { //CognitiveVR_Manager will call Core.SendData if sceneid has changed if (didChangeSceneId) { for (int i = 0; i < ActiveDynamicObjectsArray.Length; i++) { if (!ActiveDynamicObjectsArray[i].remove) { ActiveDynamicObjectsArray[i].hasEnabled = false; if (ActiveDynamicObjectsArray[i].active) { if (ActiveDynamicObjectsArray[i].IsController) { DynamicObjectCore.WriteControllerManifestEntry(ActiveDynamicObjectsArray[i]); } else { DynamicObjectCore.WriteDynamicManifestEntry(ActiveDynamicObjectsArray[i]); } } } } SendData(); //not 100% necessary. immediately sends dynamic manifest and snapshot to new scene } }
/// <summary> /// Starts a CognitiveVR session. Records hardware info, creates network manager /// </summary> public static Error Init(Transform HMDCamera) { _hmd = HMDCamera; CognitiveStatics.Initialize(); CustomEvent.Initialize(); Error error = Error.None; // Have we already initialized CognitiveVR? if (IsInitialized) { Util.logWarning("CognitiveVR has already been initialized, no need to re-initialize"); error = Error.AlreadyInitialized; } if (error == Error.None) { SetSessionProperty("c3d.app.name", Application.productName); SetSessionProperty("c3d.app.version", Application.version); SetSessionProperty("c3d.app.engine.version", Application.unityVersion); SetSessionProperty("c3d.device.type", SystemInfo.deviceType.ToString()); SetSessionProperty("c3d.device.cpu", SystemInfo.processorType); SetSessionProperty("c3d.device.model", SystemInfo.deviceModel); SetSessionProperty("c3d.device.gpu", SystemInfo.graphicsDeviceName); SetSessionProperty("c3d.device.os", SystemInfo.operatingSystem); SetSessionProperty("c3d.device.memory", Mathf.RoundToInt(SystemInfo.systemMemorySize / 1024)); DeviceId = UnityEngine.SystemInfo.deviceUniqueIdentifier; SetSessionProperty("c3d.deviceid", DeviceId); //initialize Network Manager early, before gameplay actually starts var temp = NetworkManager.Sender; DynamicManager.Initialize(); DynamicObjectCore.Initialize(); _timestamp = Util.Timestamp(); //set session timestamp if (string.IsNullOrEmpty(_sessionId)) { _sessionId = (int)SessionTimeStamp + "_" + DeviceId; } IsInitialized = true; } return(error); }