public void ReloadTransform()
        {
            if (DPSettings.config.wristHandLeft)
            {
                _wristOverlay.SetOverlayTrackedDevice(DPOverlayTrackedDevice.LeftHand);
            }
            else
            {
                _wristOverlay.SetOverlayTrackedDevice(DPOverlayTrackedDevice.RightHand);
            }

            _wristOverlay.SetOverlayTransform(DPSettings.config.wristPos, DPSettings.config.wristRot, true, true);
        }
Beispiel #2
0
        private void CalculateToolbarPos()
        {
            float amtVertical = (activeDP.overlayHeight / 2f) + 0.03f;

            amtVertical /= activeDP.transform.lossyScale.x;

            toolbarDP.SetOverlayTransform(new Vector3(0f, -amtVertical, 0f), Vector3.zero, true, true, true);
        }
Beispiel #3
0
    private void Update()
    {
        if (nightlightDP.hasBeenInitialized)
        {
            Vector3 goodPos = SteamVRManager.I.hmdTrans.position + SteamVRManager.I.hmdTrans.forward * 0.11f;

            nightlightDP.SetOverlayTransform(goodPos, SteamVRManager.I.hmdTrans.eulerAngles, true);
        }
    }
Beispiel #4
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++;
            }
        }
        private void OnOverlaysInitialized()
        {
            //They're children so we can set the local position

            gameArtDP.SetOverlayTransform(new Vector3(0f, 0f, -0.01f), Vector3.zero, true);

            closeDP.SetOverlayTransform(new Vector3(0f, -0.1f, 0f), Vector3.zero, true);

            windowListDP.SetOverlayTransform(new Vector3(0f, 0.11f, 0f), new Vector3(-15f, 0, 0f), true);
        }
        public void Show(DPOverlayBase dpBase, Vector3 pos, string name, Texture2D icon)
        {
            //if (currentDP == dpBase) return;

            //Unsub from events:
            if (currentDP != null)
            {
                currentDP.onOverlayDragged -= dragAction;
            }


            currentDP = dpBase;

            //Sub to events
            dragAction = currentDP.onOverlayDragged += delegate(bool b) {
                if (!b)
                {
                    InitUI(currentDP);
                }
            };

            InitUI(dpBase);

            textCurrent.SetText(name);
            iconCurrent.texture = icon;


            /*transCalcHMDDir.position = SteamVRManager.I.hmdTrans.position;
             * transCalcHMDDir.LookAt(dpBase.transform);*/


            //windowSettingsDP.OrphanOverlay();

            windowSettingsTopDP.SetOverlayTransform(new Vector3(0f, 0.36f, 0f), new Vector3(0f, 0f, 15f), true, true, true);

            windowSettingsDP.KillTransitions();

            windowSettingsDP.transform.position = pos;
            windowSettingsDP.transform.LookAt(2 * windowSettingsDP.transform.position - SteamVRManager.I.hmdTrans.position);

            windowSettingsDP.SyncTransform();

            windowSettingsCurrentDP.SetOverlayTransform(new Vector3(0f, 0.36f, 0), Vector3.zero);

            //dpBase.AddChildOverlay(windowSettingsDP);


            DPUIManager.Animate(windowSettingsDP, DPAnimations.FadeIn);

            isActive = true;
        }
        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();
            }
        }
        private void Start()
        {
            OverlayManager.onInitialized += OnOverlaysInitialized;


            StartCoroutine(LoadBuiltInApps());


            SteamVRManager.I.onHeadsetStateChanged.AddListener(OnHeadsetStateChanged);

            blackoutDP.onInitialized += delegate { blackoutDP.SetOverlayTransform(new Vector3(0f, 0f, 0.13f), Vector3.zero, true, true); };

            closeDP.onInteractedWith += delegate(bool b) {
                if (b)
                {
                    closeDP.TransitionOverlayWidth(0.07f, 0.3f);
                }
                else
                {
                    closeDP.TransitionOverlayWidth(0.065f, 0.2f);
                }
            };

            DPSettings.OnLoad((() => {
                SetBlackoutOpacity(DPSettings.config.dimGameAmount);
            }));

            gameArtDP.onInteractedWith += delegate(bool b) {
                CUIManager.Animate(gameHoverGroup, b);

                if (b)
                {
                    gameArtDP.TransitionOverlayWidth(0.205f, 0.2f);
                }
                else
                {
                    gameArtDP.TransitionOverlayWidth(0.2f, 0.1f);
                }
            };

            WindowListButton.onPress     += LaunchAppToMainSnap;
            WindowListButton.onHeldClose += CloseApp;


            LoadAllSnapPoints();
        }
        /// <summary>
        /// Used internally to toggle the visibility of the bar, it's children, and the DPApps
        /// </summary>
        /// <param name="visible"></param>
        private void ToggleVisible(bool visible)
        {
            isOpened = visible;


            if (!visible)
            {
                OverlayInteractionManager.I.EndCurrentDrag();

                TheBarManager.I.ToggleSnapPointsVisible(false);

                //Return focus to the active game if that's on
                if (DPSettings.config.focusGameWhenNotInteracting)
                {
                    GamingManager.FocusActiveGame();
                }


                DPUIManager.Animate(theBarDP, DPAnimation.FadeOut);
            }
            else
            {
                Vector3 goodRotBar = new Vector3(45, activatedRotation.eulerAngles.y, 0);
                theBarDP.SetOverlayTransform(GetPosFromOriginOffset(new Vector3(0, -0.45f, 0f)), goodRotBar);


                DPUIManager.Animate(theBarDP, DPAnimation.FadeInUp);
            }

            OverlayInteractionManager.I.TryEnableInteraction(visible, true);

            ToggleBlackout(visible);

            onBarOpened?.Invoke(visible);


            //Handle all the DPApps
            if (visible)
            {
                UpdateAnchoredAppsTransform();
            }

            ToggleApps(visible);
        }
        private IEnumerator Show()
        {
            //Vector3 posDetails = LibraryApp.I.dpMain.transform.position + LibraryApp.I.dpMain.transform.forward * -0.06f + LibraryApp.I.dpMain.transform.right * 0.13f;
            //Vector3 posDetailsGame = LibraryApp.I.dpMain.transform.position + LibraryApp.I.dpMain.transform.forward * -0.06f + LibraryApp.I.dpMain.transform.right * -0.13f;


            //detailsDP.SetOverlayTransform(posDetails, LibraryApp.I.dpMain.transform.eulerAngles, true, true, false);
            //detailsGameDP.SetOverlayTransform(posDetailsGame, LibraryApp.I.dpMain.transform.eulerAngles, true, true, false);

            detailsDP.SetOverlayTransform(new Vector3(0.17f, 0f, -0.07f), Vector3.zero, true);
            detailsGameDP.SetOverlayTransform(new Vector3(-0.17f, 0f, -0.07f), Vector3.zero, true);

            DPUIManager.Animate(detailsDP, DPAnimations.FadeInUp);
            DPUIManager.Animate(detailsGameDP, DPAnimations.FadeInUp);


            isShowing = true;

            yield break;
        }
Beispiel #11
0
        public void ShowKeyboard(DPOverlayBase dpBase, bool child = true)
        {
            //if (activeDP == dpBase) return;

            if (dpBase == keyboardDP)
            {
                return;
            }


            activeDP = dpBase;

            //keyboardDP.OrphanOverlay();

            Vector3 goodPos;
            Vector3 goodRot;

            /*if (child) {
             *      activeDP.AddChildOverlay(keyboardDP);
             *
             *      keyboardDP.overlay.SetWidthInMeters(0.8f);
             *
             *      goodPos = new Vector3(0f, activeDP.overlayHeight / -1.9f, -0.21f);
             *
             *      goodRot = new Vector3(30f, 0f, 0f);
             * }
             * else {*/
            goodPos  = activeDP.transform.position + activeDP.transform.forward * -0.11f;
            goodPos += activeDP.transform.up * (activeDP.overlayHeight / 2f);

            goodRot   = SteamVRManager.I.hmdTrans.eulerAngles;
            goodRot.z = 0f;
            //}


            keyboardDP.SetOverlayTransform(goodPos, goodRot);


            TheBarManager.I.ToggleDPApp(dpBase.dpAppParent, true, true);
        }