Esempio n. 1
0
        public SerializedFeedback OnSerializePreferences()
        {
            if (m_SerializedFeedback != null)
            {
                var count  = m_RequestData.Count;
                var keys   = new RequestKey[count];
                var values = new RequestData[count];
                count = 0;
                foreach (var kvp in m_RequestData)
                {
                    keys[count]   = kvp.Key;
                    values[count] = kvp.Value;
                    count++;
                }

                m_SerializedFeedback.keys   = keys;
                m_SerializedFeedback.values = values;
            }

            return(m_SerializedFeedback);
        }
Esempio n. 2
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         feedbackKey = new RequestKey(request);
            RequestData data;

            if (!m_RequestData.TryGetValue(feedbackKey, out data))
            {
                data = new RequestData();
                m_RequestData[feedbackKey] = data;
            }

            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: () =>
                            {
                                if (!data.visibleThisPresentation)
                                {
                                    data.presentations++;
                                }

                                data.visibleThisPresentation = true;
                            });
                        }
                    }
                }
            }
        }