Esempio n. 1
0
        private void Update()
        {
            if (GazeSelector != null && !LockSelectedTarget)
            {
                IList <RaycastHit>  targets       = GazeSelector.SelectedTargets;
                GazeSelectionTarget desiredTarget = (targets != null && targets.Count > 0 && targets[0].transform != null)
                    ? GetGazeSelectionTarget(targets[0].transform.gameObject)
                    : null;

                // reset our unselected time
                if (desiredTarget == selectedTarget)
                {
                    timeUnselected = 0.0f;
                }
                else
                {
                    timeUnselected += Time.deltaTime;

                    // unselected long enough to have a new target
                    if (timeUnselected >= DelayTimeSwitchingTargets)
                    {
                        SelectedTarget = desiredTarget;
                        timeUnselected = 0.0f;

                        // the selected target change can cause states to change; update selected target once more to ensure that our target really switched
                        // for example: POIs turn different cards on and off and depending on their bounds, the target may swap states repeatedly; this
                        // prevents that from happening
                        GazeSelector.Update();
                        SelectedTarget = desiredTarget = (targets != null && targets.Count > 0 && targets[0].transform != null)
                            ? GetGazeSelectionTarget(targets[0].transform.gameObject)
                            : null;
                    }
                }
            }
        }
Esempio n. 2
0
        private GazeSelectionTarget GetGazeSelectionTarget(GameObject target)
        {
            GazeSelectionTarget selectionTarget = null;

            while (target != null && selectionTarget == null)
            {
                selectionTarget = target.GetComponent <GazeSelectionTarget>();

                target = target.transform.parent != null
                    ? target.transform.parent.gameObject
                    : null;
            }

            return(selectionTarget);
        }
        public void HideCard()
        {
            if (CardAnimator && CardAnimator.GetBool("CardVisible"))
            {
                isCardSelected = false;
                CardPOIManager.Instance.CanTapCard = true;
                descriptionAnimator.SetBool("selected", false);

                if (targetOffsetObject != null)
                {
                    Destroy(targetOffsetObject);
                    targetOffsetObject = null;
                }

                CardAnimator.SetBool("CardVisible", false);

                AudioSource cardAudioSource = CardAnimator.GetComponent <AudioSource>();
                if (DeselectSound != null && cardAudioSource != null)
                {
                    VOManager.Instance.Stop(clearQueue: true);
                    cardAudioSource.PlayOneShot(DeselectSound);
                }

                // slide in the description
                StopAllCoroutines();
                Vector3 startWorldPosition = Description.transform.position;
                Description.transform.parent.SetParent(descriptionOriginalParenting, true);
                Description.transform.parent.localPosition = Vector3.zero;
                Description.transform.parent.localScale    = Vector3.one;
                StartCoroutine(SlideCardIn(startWorldPosition));

                // fade in the points of interest when the card is unselected
                if (TransitionManager.Instance != null)
                {
                    foreach (PointOfInterest pointOfInterest in pointsOfInterest)
                    {
                        if (pointOfInterest != null)
                        {
                            // if faders has their coroutines killed, then need to be initialized to a disabled state
                            Fader[] faders = pointOfInterest.GetComponentsInChildren <Fader>(true);
                            foreach (Fader fader in faders)
                            {
                                fader.DisableFade();
                            }

                            if (pointOfInterest == this)
                            {
                                BillboardLine.LineFader fader = GetComponentInChildren <BillboardLine.LineFader>(true);
                                if (fader != null)
                                {
                                    StartCoroutine(TransitionManager.Instance.FadeContent(
                                                       fader.gameObject,
                                                       TransitionManager.FadeType.FadeIn,
                                                       CardPOIManager.Instance.POIFadeOutTime,
                                                       CardPOIManager.Instance.POIOpacityCurve));
                                }
                            }
                            else
                            {
                                StartCoroutine(TransitionManager.Instance.FadeContent(
                                                   pointOfInterest.gameObject,
                                                   TransitionManager.FadeType.FadeIn,
                                                   CardPOIManager.Instance.POIFadeOutTime,
                                                   CardPOIManager.Instance.POIOpacityCurve));
                            }
                        }
                    }
                }

                // we can hide the text again
                GazeSelectionTarget selectionTarget = GazeSelectionManager.Instance.SelectedTarget;
                if (selectionTarget != this ||                                                                                                                         // same selection target
                    (selectionTarget != null && selectionTarget is PointOfInterestReference && (selectionTarget as PointOfInterestReference).pointOfInterest != this)) // same target hidden by a reference
                {
                    OnGazeDeselect();
                }
            }
        }