コード例 #1
0
ファイル: XRHeightOffset.cs プロジェクト: tuita520/handUI
        private void OnDrawGizmos()
        {
            Gizmos.color = Color.Lerp(Color.magenta, Color.white, 0.3f).WithAlpha(0.5f);

            var totalHeight      = roomScaleHeightOffset;
            var segmentsPerMeter = 32;
            var numSegments      = totalHeight * segmentsPerMeter;
            var segmentLength    = totalHeight / numSegments;
            var rigPos           = this.transform.position;
            var down             = this.transform.rotation * Vector3.down;

            if (Application.isPlaying && XRSupportUtil.IsRoomScale())
            {
                var roomScaleGizmoOffset = Vector3.up * totalHeight;

                rigPos += roomScaleGizmoOffset;
            }

            for (int i = 0; i < numSegments; i += 2)
            {
                var segStart = rigPos + down * segmentLength * i;
                var segEnd   = rigPos + down * segmentLength * (i + 1);

                Gizmos.DrawLine(segStart, segEnd);
            }

            var groundPos = rigPos + down * totalHeight;

            drawCircle(groundPos, down, 0.01f);
            Gizmos.color = Gizmos.color.WithAlpha(0.3f);
            drawCircle(groundPos, down, 0.10f);
            Gizmos.color = Gizmos.color.WithAlpha(0.2f);
            drawCircle(groundPos, down, 0.20f);
        }
コード例 #2
0
ファイル: XRHeightOffset.cs プロジェクト: tuita520/handUI
        private void Start()
        {
            _lastKnownHeightOffset = _roomScaleHeightOffset;

            if (XRSupportUtil.IsRoomScale())
            {
                this.transform.position -= this.transform.up * _roomScaleHeightOffset;
            }

            if (recenterOnStart)
            {
                XRSupportUtil.Recenter();
            }
        }
コード例 #3
0
ファイル: XRHeightOffset.cs プロジェクト: tuita520/handUI
        private void Update()
        {
            if (Application.isPlaying)
            {
                var deviceIsPresent = XRSupportUtil.IsXRDevicePresent();
                if (deviceIsPresent)
                {
                    if (enableRuntimeAdjustment)
                    {
                        if (Input.GetKeyDown(stepUpKey))
                        {
                            roomScaleHeightOffset += stepSize;
                        }

                        if (Input.GetKeyDown(stepDownKey))
                        {
                            roomScaleHeightOffset -= stepSize;
                        }
                    }

                    if (recenterOnUserPresence && !XRSupportUtil.IsRoomScale())
                    {
                        var userPresence = XRSupportUtil.IsUserPresent();

                        if (_lastUserPresence != userPresence)
                        {
                            if (userPresence)
                            {
                                XRSupportUtil.Recenter();
                            }

                            _lastUserPresence = userPresence;
                        }
                    }

                    if (recenterOnKey && Input.GetKeyDown(recenterKey))
                    {
                        XRSupportUtil.Recenter();
                    }
                }
            }
        }