/// <summary> /// Renders the specified event. /// </summary> /// <param name="evt"> /// The event to render /// </param> /// <param name="entity"> /// The GameObject that represents the entity. /// </param> /// <returns> /// The <see cref="GameObject"/> that was created to represent the event. /// </returns> public GameObject RenderEvent(ReportableFocusEvent evt, GameObject entity) { // Validate parameters if (evt == null) { throw new ArgumentNullException(nameof(evt)); } if (entity == null) { throw new ArgumentNullException(nameof(entity)); } // Create a prefab instance that matches the record type var record = CreatePrefab(evt.EventType); // Make it a child of the entity so it moves with the entity // We use worldPositionStays: true even though we're going to change its // position because this makes sure the original prefabs scale is maintained record.transform.SetParent(entity.transform, worldPositionStays: true); // Position it correctly record.transform.localPosition = evt.LocalPosition; // Return it return(record); }
protected async void LocalInsertReportableFocusEvent(ReportableFocusEvent rfe) { Assert.IsNotNull <ReportableFocusEvent>(rfe); IMobileServiceSyncTable <ReportableFocusEvent> localTable = Client.GetSyncTable <ReportableFocusEvent>(); try { await localTable.InsertAsync(rfe); Debug.Log($"Recording: {rfe.EventType} on {rfe.EntityName} at {rfe.LocalPosition}"); } catch (Exception e) { Debug.LogError(e.ToString()); } }
private void RecordEvent(IPointingSource source, TriggerType triggerType) { // Get the event type var eventType = GetEventType(source, triggerType); // Is this gaze or controller? bool isGaze = (source is GazeManager); // Placeholders Vector3 worldPosition, localPosition; // Exit events need to be handled differently because exit events do not occur "on object" if (triggerType != TriggerType.Exit) { // Use the position from the pointing source worldPosition = source.Result.End.Point; localPosition = transform.InverseTransformPoint(worldPosition); // Update last known positions for eventual exit event lastWorldPosition = worldPosition; lastLocalPosition = localPosition; } else { // It is an exit event, use the last known position "on object" worldPosition = lastWorldPosition; localPosition = lastLocalPosition; } // If recording for this event is not enabled, skip the rest of this event if (!IsEnabled(eventType)) { return; } // Calculate remaining parameters string packageToken = HardwareIdentification.GetPackageSpecificToken(); string sourceName = (isGaze ? "Gaze" : "Controller"); // Create event ReportableFocusEvent evt = new ReportableFocusEvent(packageToken, EntityName, sourceName, eventType, DateTimeOffset.Now, localPosition, worldPosition); // Report event AnalyticsFocusReporter.Instance.InsertReportableFocusEvent(evt); }
public void InsertReportableFocusEvent(ReportableFocusEvent rfe) { LocalInsertReportableFocusEvent(rfe); }