Пример #1
0
        void ShowFeedback(VRInputDevice.VRControl control)
        {
            if (m_FeedbackRequests.ContainsKey(control))
            {
                return;
            }

            var request = new ProxyFeedbackRequest
            {
                control  = control,
                node     = node,
                duration = -1
            };

            m_FeedbackRequests[control] = request;
            this.AddFeedbackRequest(request);
        }
Пример #2
0
        public void RemoveFeedbackRequest(ProxyFeedbackRequest request)
        {
            foreach (var affordance in m_Affordances)
            {
                if (affordance.control != request.control)
                {
                    continue;
                }

                foreach (var renderer in affordance.renderers)
                {
                    m_AffordanceData[renderer].SetVisibility(false, request.duration, request.control);

                    this.SetHighlight(renderer.gameObject, false);

                    if (!string.IsNullOrEmpty(request.tooltipText))
                    {
                        foreach (var tooltip in affordance.tooltips)
                        {
                            if (tooltip)
                            {
                                tooltip.tooltipText = string.Empty;
                                this.HideTooltip(tooltip, true);
                            }
                        }
                    }
                }
            }

            foreach (var feedbackRequest in m_FeedbackRequests)
            {
                if (feedbackRequest == request)
                {
                    m_FeedbackRequests.Remove(feedbackRequest);

                    if (!request.showBody)
                    {
                        ExecuteFeedback(request);
                    }

                    break;
                }
            }
        }
Пример #3
0
        void ExecuteFeedback(ProxyFeedbackRequest changedRequest)
        {
            if (!isActiveAndEnabled)
            {
                return;
            }

            if (changedRequest.showBody)
            {
                foreach (var tuple in m_BodyData)
                {
                    tuple.secondElement.SetVisibility(true, changedRequest.duration);
                }
                return;
            }

            ProxyFeedbackRequest request = null;

            foreach (var feedbackRequest in m_FeedbackRequests)
            {
                if (feedbackRequest.control != changedRequest.control || feedbackRequest.showBody != changedRequest.showBody)
                {
                    continue;
                }

                if (request == null || feedbackRequest.priority >= request.priority)
                {
                    request = feedbackRequest;
                }
            }

            if (request == null)
            {
                return;
            }

            var requestKey = GetRequestKey();

            requestKey.UpdateValues(request);
            RequestData data;

            if (!m_RequestData.TryGetValue(requestKey, out data))
            {
                data = new RequestData();
                m_RequestData[requestKey] = data;
            }
            else
            {
                m_RequestKeyPool.Enqueue(requestKey);
            }

            var suppress             = data.presentations > request.maxPresentations - 1;
            var suppressPresentation = request.suppressPresentation;

            if (suppressPresentation != null)
            {
                suppress = suppressPresentation();
            }

            if (suppress)
            {
                return;
            }

            foreach (var affordance in m_Affordances)
            {
                if (affordance.control != request.control)
                {
                    continue;
                }

                m_AffordanceData[affordance.renderer].SetVisibility(!request.suppressExisting, request.duration, changedRequest.control);

                this.SetHighlight(affordance.renderer.gameObject, !request.suppressExisting);

                var tooltipText = request.tooltipText;
                if (!string.IsNullOrEmpty(tooltipText) || request.suppressExisting)
                {
                    foreach (var tooltip in affordance.tooltips)
                    {
                        if (tooltip)
                        {
                            data.visibleThisPresentation = false;
                            tooltip.tooltipText          = tooltipText;
                            this.ShowTooltip(tooltip, true, placement: tooltip.GetPlacement(m_FacingDirection),
                                             becameVisible: data.onBecameVisible);
                        }
                    }
                }
            }
        }
Пример #4
0
 public void AddFeedbackRequest(ProxyFeedbackRequest request)
 {
     m_FeedbackRequests.Add(request);
     ExecuteFeedback(request);
 }
Пример #5
0
 public RequestKey(ProxyFeedbackRequest request)
 {
     m_Control     = request.control;
     m_TooltipText = request.tooltipText;
 }
Пример #6
0
 public void UpdateValues(ProxyFeedbackRequest request)
 {
     m_Control     = request.control;
     m_TooltipText = request.tooltipText;
 }