private void Update()
        {
            //Initalize the popup to be in front of the user.
            if (isFirstMove)
            {
                isFirstMove = false;

                Vector3 finalPos = _hmdTransform.position + _hmdTransform.forward * offsetForward;
                finalPos = new Vector3(finalPos.x, finalPos.y - offsetDown, finalPos.z);

                _notifPopupOverlay.transform.position = finalPos;


                _notifPopupOverlay.transform.rotation = _hmdTransform.rotation;

                _notifPopupOverlay.SetOverlayPositionWithCurrent(false);
            }

            if (popupIsActive)
            {
                Vector3 velocity = Vector3.zero;

                Vector3 finalPos = _hmdTransform.position + _hmdTransform.forward * offsetForward;
                finalPos = new Vector3(finalPos.x, finalPos.y - offsetDown, finalPos.z);

                _notifPopupOverlay.transform.position = Vector3.SmoothDamp(_notifPopupOverlay.transform.position, finalPos, ref velocity, 0.3f);

                //_notifPopupOverlay.SetOverlayTransform(
                //Vector3.SmoothDamp(_notifPopupOverlay.transform.position, finalPos, ref velocity, 0.3f),
                //.transform.localEulerAngles, true, true);


                Quaternion curRot = _notifPopupOverlay.transform.rotation;
                Quaternion desRot = _hmdTransform.rotation;


                _notifPopupOverlay.transform.rotation = Quaternion.Lerp(curRot, desRot, Time.deltaTime);

                _notifPopupOverlay.SetOverlayTransform(_notifPopupOverlay.transform.position, _notifPopupOverlay.transform.eulerAngles, false, false);
            }

            if (flyToWatch)
            {
                Vector3 finalPos = Vector3.Lerp(_notifPopupOverlay.transform.position,
                                                _wristboardOverlay.transform.position, Time.deltaTime * 4);

                _notifPopupOverlay.transform.position = finalPos;

                _notifPopupOverlay.SetOverlayPositionWithCurrent();
            }
        }
Esempio n. 2
0
        private void _showPopup(string phraseStart, PopupFacingDir dir, DPCameraOverlay dpParent, RectTransform element)
        {
            //Check to see if the user is still hovering on the same element or not
            if (_potentialPopupElement != element)
            {
                return;
            }

            //Debug.Log(offset);

            _popupShouldBeActive = true;


            title.SetText(LeanLocalization.GetTranslationText(phraseStart + "Title"));
            desc.SetText(LeanLocalization.GetTranslationText(phraseStart + "Desc"));

            title.ForceMeshUpdate();
            desc.ForceMeshUpdate();


            //Canvas.ForceUpdateCanvases();
            LayoutRebuilder.ForceRebuildLayoutImmediate(bg);
            bg.gameObject.SetActive(false);
            bg.gameObject.SetActive(true);

            //transform.parent.GetComponent<VerticalLayoutGroup>().enabled = false;
            //transform.parent.GetComponent<VerticalLayoutGroup>().enabled = true;

            //fitter.enabled = false;
            //fitter.enabled = true;


            //Figure out the right location:
            Vector3 spawnOffset;


            switch (dir)
            {
            case PopupFacingDir.Left:
                spawnOffset            = new Vector3(1, 0, 0);
                arrow.anchoredPosition = new Vector2(-123 - 5, ((bg.rect.height + bg.rect.position.y) / 2) + 5);
                arrow.localEulerAngles = new Vector3(0, 0, -90);

                break;

            default:
            case PopupFacingDir.Down:
                spawnOffset            = new Vector3(0, 0.08f, -0.01f);
                arrow.anchoredPosition = new Vector2(0, 0);
                arrow.localEulerAngles = new Vector3(0, 0, 0);

                break;


            case PopupFacingDir.Right:
                spawnOffset            = new Vector3(-1, 0, 0);
                arrow.anchoredPosition = new Vector2(123, ((bg.rect.height + bg.rect.position.y) / 2) + 5);
                arrow.localEulerAngles = new Vector3(0, 0, 90);

                break;

            case PopupFacingDir.TheBar:
                spawnOffset            = new Vector3(0, 0.1f, 0.06f);
                arrow.anchoredPosition = new Vector2(0, 0);
                arrow.localEulerAngles = new Vector3(0, 0, 0);

                break;
            }


            //Vector3 dpPos = dpParent.transform.position;


            Vector3 goodRot = new Vector3(0, dpParent.transform.eulerAngles.y, 0);


            dpParent.SetOtherTransformRelativeToElement(hoverDP.transform, element, spawnOffset);

            hoverDP.SetOverlayPositionWithCurrent(true, false);


            //hoverDP.SetOverlayPosition(goodPos, goodRot, true, false);
            hoverDP.TransitionOverlayOpacity(1f, 0.5f);


            hoverDP.RequestRendering(true);

            _popupIsActive = true;
        }