/// <summary>
        /// Start recording a session. Sets SceneId, records basic hardware information, starts coroutines to record other data points on intervals
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="userProperties"></param>
        public void Initialize(string userName = "", List <KeyValuePair <string, object> > userProperties = null)
        {
            if (instance != null && instance != this)
            {
                Util.logDebug("CognitiveVR_Manager Initialize instance is not null and not this! Destroy");
                Destroy(gameObject);
                return;
            } //destroy if there's already another manager
            if (Core.IsInitialized)
            {
                Util.logWarning("CognitiveVR_Manager Initialize - Already Initialized!");
                return;
            } //skip if a session has already been initialized

            if (!CognitiveVR_Preferences.Instance.IsApplicationKeyValid)
            {
                Util.logDebug("CognitiveVR_Manager Initialize does not have valid apikey");
                return;
            }

#if CVR_STEAMVR
            SteamVR_Events.NewPoses.AddListener(OnPoseUpdate); //steamvr 1.2
            PoseUpdateEvent += PoseUpdateEvent_ControllerStateUpdate;
            //SteamVR_Utils.Event.Listen("new_poses", OnPoseUpdate); //steamvr 1.1
#endif

#if CVR_STEAMVR2
            Valve.VR.SteamVR_Events.NewPoses.AddListener(OnPoseUpdate);
            PoseUpdateEvent += PoseUpdateEvent_ControllerStateUpdate;
#endif

            UnityEngine.SceneManagement.SceneManager.sceneLoaded += SceneManager_SceneLoaded;

            //get all loaded scenes. if one has a sceneid, use that
            var count = UnityEngine.SceneManagement.SceneManager.sceneCount;
            UnityEngine.SceneManagement.Scene scene = new UnityEngine.SceneManagement.Scene();
            for (int i = 0; i < count; i++)
            {
                scene = UnityEngine.SceneManagement.SceneManager.GetSceneAt(i);
                var cogscene = CognitiveVR_Preferences.FindSceneByPath(scene.path);
                if (cogscene != null)
                {
                    Core.SetTrackingScene(cogscene);
                    break;
                }
            }

            Core.UserId = userName;
            Core.SetSessionProperty("c3d.username", userName);

            //sets session properties for system hardware
            Error initError = CognitiveVR.Core.Init(GameplayReferences.HMD);

            Core.InvokeLevelLoadedEvent(scene, UnityEngine.SceneManagement.LoadSceneMode.Single, true);

            //on init stuff here
            initResponse = initError;

            if (initError == Error.None)
            {
                new CustomEvent("c3d.sessionStart").Send();
                if (CognitiveVR_Preferences.Instance.TrackGPSLocation)
                {
                    Input.location.Start(CognitiveVR_Preferences.Instance.GPSAccuracy, CognitiveVR_Preferences.Instance.GPSAccuracy);
                    Input.compass.enabled = true;
                    if (CognitiveVR_Preferences.Instance.SyncGPSWithGaze)
                    {
                        //just get gaze snapshot to grab this
                    }
                    else
                    {
                        StartCoroutine(GPSTick());
                    }
                }
                playerSnapshotInverval = new WaitForSeconds(CognitiveVR.CognitiveVR_Preferences.S_SnapshotInterval);
                GPSUpdateInverval      = new WaitForSeconds(CognitiveVR_Preferences.Instance.GPSInterval);
                StartCoroutine(Tick());
                Util.logDebug("CognitiveVR Initialized");
            }
            else //some failure
            {
                StopAllCoroutines();
                Util.logDebug("CognitiveVR Error" + initError.ToString());
            }

            var components = GetComponentsInChildren <CognitiveVR.Components.CognitiveVRAnalyticsComponent>();
            for (int i = 0; i < components.Length; i++)
            {
                components[i].CognitiveVR_Init(initError);
            }

            switch (CognitiveVR_Preferences.Instance.GazeType)
            {
            case GazeType.Physics: gameObject.AddComponent <PhysicsGaze>().Initialize(); break;

            case GazeType.Command: gameObject.AddComponent <CommandGaze>().Initialize(); break;
                //case GazeType.Sphere: gameObject.AddComponent<SphereGaze>().Initialize(); break;
            }
#if CVR_TOBIIVR || CVR_AH || CVR_FOVE || CVR_PUPIL || CVR_VIVEPROEYE || CVR_VARJO
            //fixation requires some kind of eye tracking hardware
            FixationRecorder fixationRecorder = gameObject.GetComponent <FixationRecorder>();
            if (fixationRecorder == null)
            {
                fixationRecorder = gameObject.AddComponent <FixationRecorder>();
            }
            fixationRecorder.Initialize();
#endif

            //if (InitEvent != null) { InitEvent(initError); }
            Core.InvokeInitEvent(initError);

            CognitiveVR.NetworkManager.InitLocalStorage(System.Environment.NewLine);

            SetSessionProperties();

            if (userProperties != null)
            {
                Core.SetSessionProperties(userProperties);
            }
        }
 public void SetTarget(FixationRecorder target)
 {
     fixationRecorder = target;
 }