private void LoadContextTimelineData(ViRMA_TimelineChild targetTimelineChild) { if (isContextTimeline == false) { savedTimelineSection = currentTimelineSection; savedTimelineChildId = targetTimelineChild.id; } StartCoroutine(ViRMA_APIController.GetContextTimeline(targetTimelineChild.timestamp, contextTimelineTimespan, (results) => { contextTimelineResults = results; if (contextTimelineResults.Count > 0) { if (contextTimelineResults.Count >= resultsRenderSize) { if (contextTimelineResults.Count % resultsRenderSize == 0) { totalContextTimelineSections = (contextTimelineResults.Count / resultsRenderSize); } else { totalContextTimelineSections = (contextTimelineResults.Count / resultsRenderSize) + 1; } } else { totalContextTimelineSections = 1; } int targetSection = 0; for (int i = 0; i < contextTimelineResults.Count; i++) { if (contextTimelineResults[i].Key == targetTimelineChild.id) { targetContextTimelineChildId = contextTimelineResults[i].Key; targetSection = i / resultsRenderSize; //Debug.Log(i + " divided by " + resultsRenderSize + " --> Target Section: " + targetSection); break; } } isContextTimeline = true; LoadTimelineSection(targetSection, totalContextTimelineSections); } })); }
public void SubmitContextMenuBtn(SteamVR_Action_Boolean action, SteamVR_Input_Sources source) { if (hoveredContextMenuBtn != null) { ViRMA_TimeLineContextMenuBtn btnOption = hoveredContextMenuBtn.GetComponent <ViRMA_TimeLineContextMenuBtn>(); ViRMA_TimelineChild targetTimelineChild = btnOption.targetTimelineChild.GetComponent <ViRMA_TimelineChild>(); if (btnOption.btnType.ToLower() == "context") { LoadContextTimelineData(targetTimelineChild); } if (btnOption.btnType.ToLower() == "submit") { string submissionId = btnOption.targetTimelineChild.GetComponent <ViRMA_TimelineChild>().fileName; StartCoroutine(ViRMA_CompetitionController.SubmitToLSC(submissionId, (result) => { StartCoroutine(SubmissionFeedback(btnOption.targetTimelineChild, result)); })); } } }
private void PositionTimeline(int newSectionIndex) { // if this is the first time positioning the timeline, pick a space in front of the user, otherwise use the active position and rotation if (activeTimelinePosition == Vector3.one * Mathf.Infinity || activeTImelineRotation == Quaternion.identity) { float distance = timelinePositionDistance; Vector3 flattenedVector = Player.instance.bodyDirectionGuess; flattenedVector.y = 0; flattenedVector.Normalize(); transform.position = Player.instance.hmdTransform.position + (flattenedVector * distance); transform.LookAt(2 * transform.position - Player.instance.hmdTransform.position); activeTimelinePosition = transform.position; activeTImelineRotation = transform.rotation; } else { transform.position = activeTimelinePosition; transform.rotation = activeTImelineRotation; } // generate max right and left positions for timeline to move between Transform lastChild = timelineChildrenWrapper.transform.GetChild(timelineChildrenWrapper.transform.childCount - 1); float offsetDistance = Vector3.Distance(transform.position, lastChild.position); Vector3 offset = transform.right * offsetDistance; maxLeft = transform.position - offset; maxRight = transform.position; // set timeline to correct position, and offset it slightly so nav buttons aren't the first thing seen if (newSectionIndex < currentTimelineSection) { if (nextBtn) { float distBetweenChildAndNav = Vector3.Distance(lastRealChild.transform.position, nextBtn.transform.position); Vector3 childNavOffset = transform.right * distBetweenChildAndNav; transform.position = maxLeft + childNavOffset; } } else { if (prevBtn) { float distBetweenChildAndNav = Vector3.Distance(firstRealChild.transform.position, prevBtn.transform.position); Vector3 childNavOffset = transform.right * distBetweenChildAndNav; transform.position = maxRight - childNavOffset; } } // if the target context menu child is rendered, or if returning to cell contents timeline, use a child as the focus if (targetContextTimelineChild) { Transform firstChild = timelineChildrenWrapper.transform.GetChild(0); float distBetweenChildAndStart = Vector3.Distance(firstChild.position, targetContextTimelineChild.transform.position); Vector3 targetChildOffset = transform.right * distBetweenChildAndStart; transform.position = maxRight - targetChildOffset; } else if (savedTimelineChildId != 0) { for (int i = 0; i < timelineSectionChildren.Count; i++) { ViRMA_TimelineChild targetChild = timelineSectionChildren[i].GetComponent <ViRMA_TimelineChild>(); if (targetChild.id == savedTimelineChildId) { Transform firstChild = timelineChildrenWrapper.transform.GetChild(0); float distBetweenChildAndStart = Vector3.Distance(firstChild.position, targetChild.transform.position); Vector3 targetChildOffset = transform.right * distBetweenChildAndStart; transform.position = maxRight - targetChildOffset; //targetChild.ToggleBorder(true); break; } } } }