public void UnhideCard() { if (CardAnimator && !CardAnimator.GetBool("CardVisible")) { isCardSelected = true; CardAnimator.SetBool("CardVisible", true); descriptionAnimator.SetBool("selected", true); // update the position of the image and face the camera CardAnimator.transform.parent.position = IndicatorLine.points[0].position; if (Camera.main != null) { Vector3 forwardDirection = transform.position - Camera.main.transform.position; CardAnimator.transform.parent.rotation = Quaternion.LookRotation(forwardDirection.normalized, Camera.main.transform.up); } AudioSource cardAudioSource = CardAnimator.GetComponent <AudioSource>(); if (AirtapSound != null && cardAudioSource != null) { VOManager.Instance.Stop(clearQueue: true); VOManager.Instance.PlayClip(AirtapSound); cardAudioSource.PlayOneShot(SelectSound); } // slide out the description StopAllCoroutines(); Description.transform.localPosition = descriptionStoppedLocalPosition; targetDescriptionScale = Mathf.Max(Description.transform.lossyScale.x, Description.transform.lossyScale.y, Description.transform.lossyScale.z); ScaleWithDistance distanceScaler = CardAnimator.transform.parent.GetComponentInChildren <ScaleWithDistance>(); Description.transform.parent.SetParent(distanceScaler.transform, true); targetOffsetObject = new GameObject("DescriptionOffset"); targetOffsetObject.transform.SetParent(CardAnimator.transform.parent); StartCoroutine(SlideCardOut()); // fade out the points of interest when the card is selected 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.FadeOut, CardPOIManager.Instance.POIFadeOutTime, CardPOIManager.Instance.POIOpacityCurve)); } } else { StartCoroutine(TransitionManager.Instance.FadeContent( pointOfInterest.gameObject, TransitionManager.FadeType.FadeOut, CardPOIManager.Instance.POIFadeOutTime, CardPOIManager.Instance.POIOpacityCurve)); } } } } } }
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(); } } }