Esempio n. 1
0
        // --- Cursor management ---

        private void ShowCursorsAtInteractionPoints(DPOverlayBase dpBase, List <Vector3> interactionPoints)
        {
            foreach (Vector3 point in interactionPoints)
            {
                //Un-offset to be centered again
                //Vector2 fixedPoint = new Vector2(point.x - dpBase.overlay.width / 2f, point.y - dpBase.overlayHeight / 2f);
                //Debug.Log(fixedPoint.x);

                if (_cursorsDPPool.Count <= _cursorPoolIndex)
                {
                    _cursorsDPPool.Add(Instantiate(cursorPF, SteamVRManager.I.noAnchorTrans).GetComponent <DPCursor>());
                    _cursorsDPPool[_cursorPoolIndex].cursorDP.PreInitialize();
                    _cursorsDPPool[_cursorPoolIndex].cursorDP.overlay.SetSortOrder(100);
                    _cursorsDPPool[_cursorPoolIndex].cursorDP.RequestRendering();
                    //Debug.Log("added cursor");
                }

                DPCameraOverlay cursorDP = _cursorsDPPool[_cursorPoolIndex].cursorDP;
                DPCursor        cursor   = _cursorsDPPool[_cursorPoolIndex];


                //Get the distance to the overlay
                float distance = Vector3.Distance(SteamVRManager.I.hmdTrans.position, point);

                distance /= 100f;
                cursorDP.overlay.SetWidthInMeters(0.001f + distance);

                //Set position, if new overlay, jump instantly

                if (cursor.targetDP != dpBase)
                {
                    cursorDP.transform.position = point;

                    cursor.targetDP = dpBase;
                }
                else
                {
                    cursorDP.transform.position = Vector3.Lerp(cursorDP.transform.position, point, Time.deltaTime * 30f);
                }


                cursorDP.transform.LookAt(2 * cursorDP.transform.position - SteamVRManager.I.hmdTrans.position);

                //cursor.transform.LookAt(SteamVRManager.I.hmdTrans);


                cursorDP.SetOverlayTransform(cursorDP.transform.position, cursorDP.transform.eulerAngles, false);

                if (!cursorDP.overlay.isVisible)
                {
                    cursorDP.overlay.SetVisible(true);
                }

                _cursorPoolIndex++;
            }
        }
Esempio n. 2
0
        private IEnumerator _tryShowPopup(string phraseStart, PopupFacingDir dir, DPCameraOverlay dpParent, RectTransform element)
        {
            _potentialPopupElement = element;

            if (!_popupIsActive)
            {
                _popupShouldBeActive = true;

                //Wait and then see if they're still hovering over the same thing
                yield return(new WaitForSeconds(hoverBeforeShow));

                //If the tryEnd got triggered while waiting, break
                if (!_popupShouldBeActive)
                {
                    yield break;
                }
            }


            _showPopup(phraseStart, dir, dpParent, element);
        }
Esempio n. 3
0
 /// <summary>
 /// Displays a popup with the requested phrase (adds on Title and Desc when needed to the string name).
 /// </summary>
 public void TryShowPopup(string phraseStart, PopupFacingDir dir, DPCameraOverlay dpParent, RectTransform element)
 {
     StartCoroutine(_tryShowPopup(phraseStart, dir, dpParent, element));
 }
Esempio n. 4
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;
        }
Esempio n. 5
0
        public void PlaySoundOnDPCam(DPCameraOverlay dpCam, Vector2 elementPos, DPSoundEffect sound)
        {
            Vector3 pos = dpCam.GetWorldPositionOverlayElement(elementPos, Vector3.zero);

            PlaySoundInWorld(pos, sound);
        }