Ejemplo n.º 1
0
 // Start is called before the first frame update
 void Start()
 {
     try
     {
         xr.TryGetBoundaryPoints(boundryPoints);
         xr.boundaryChanged += delegate(XRInputSubsystem i)
         {
             i.TryGetBoundaryPoints(boundryPoints);
         };//Hopefully I'll get updated boundry points now
     }
     catch { }
 }
        public IEnumerator TestFloorTrackingOriginMode()
        {
            yield return(new WaitForSeconds(1));

            XRInputSubsystem inputSub = ActiveLoader.GetLoadedSubsystem <XRInputSubsystem>();

            if (inputSub.GetTrackingOriginMode() == TrackingOriginModeFlags.Floor)
            {
                List <Vector3> boundaryPoints = new List <Vector3>();
                inputSub.TryGetBoundaryPoints(boundaryPoints);
                Assert.IsFalse(boundaryPoints.Count == 0);
            }
        }
 public bool DrawPlayArea(XRInputSubsystem subsystem)
 {
     if (subsystem != null)
     {
         if (subsystem.TryGetBoundaryPoints(boundaryPoints))
         {
             Debug.Log($"Got {boundaryPoints.Count} boundary points");
             if (boundaryPoints.Count > 0)
             {
                 ReadBoundPoints();
                 return(true);
             }
         }
     }
     return(false);
 }
        public IEnumerator TestBoundaryIsAtGround()
        {
            yield return(new WaitForSeconds(1));

            XRInputSubsystem inputSub = ActiveLoader.GetLoadedSubsystem <XRInputSubsystem>();

            if (inputSub.GetTrackingOriginMode() == TrackingOriginModeFlags.Floor)
            {
                List <Vector3> boundaryPoints = new List <Vector3>();
                inputSub.TryGetBoundaryPoints(boundaryPoints);
                for (int i = 0; i < boundaryPoints.Count; i++)
                {
                    Assert.That(boundaryPoints[i].y, Is.EqualTo(0.0f).Within(1).Ulps);
                }
            }
        }
    void DrawBoundary()
    {
        if (m_BoundaryLineRenderer == null)
        {
            m_BoundaryLineRenderer            = gameObject.AddComponent(typeof(LineRenderer)) as LineRenderer;
            m_BoundaryLineRenderer.startWidth = 0.05f;
            m_BoundaryLineRenderer.endWidth   = 0.05f;
        }

        List <Vector3> BoundaryPoints = new List <Vector3>();

        if (!m_InputSubsystem.TryGetBoundaryPoints(BoundaryPoints))
        {
            SetStatus("Error! TryGetBoundaryPoints failed!");
            return;
        }
        else
        {
            if (m_BoundaryPointVisualizers == null)
            {
                m_BoundaryPointVisualizers = new List <GameObject>();
            }
            else
            {
                for (int i = 0; i < m_BoundaryPointVisualizers.Count; i++)
                {
                    Destroy(m_BoundaryPointVisualizers[i]);
                }
                m_BoundaryPointVisualizers.Clear();
            }

            for (int i = 0; i < BoundaryPoints.Count; i++)
            {
                GameObject NewGameObject = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                NewGameObject.name = m_InputSubsystem.ToString() + "BoundaryPoint" + i;
                NewGameObject.transform.SetParent(m_ParentForBoundaryPoints);
                NewGameObject.transform.localPosition = BoundaryPoints[i];
                NewGameObject.transform.localScale    = new Vector3(0.05f, 0.05f, 0.05f);
                m_BoundaryPointVisualizers.Add(NewGameObject);

                if (i == 0)
                {
                    NewGameObject.GetComponent <MeshRenderer>().material.color = Color.green;

                    GameObject Signpost = new GameObject();
                    Signpost.transform.SetParent(NewGameObject.transform);
                    Signpost.transform.localPosition = Vector3.zero;

                    Signpost.AddComponent <Billboard>();

                    TextMesh StartText = Signpost.AddComponent <TextMesh>();
                    StartText.text          = ("Start of boundary\n for XRInputSubsystem " + m_SystemNumber);
                    StartText.alignment     = TextAlignment.Center;
                    StartText.anchor        = TextAnchor.MiddleCenter;
                    StartText.fontSize      = 120;
                    StartText.characterSize = 0.01f;
                    StartText.color         = Color.green;
                }
            }

            m_BoundaryLineRenderer.positionCount = BoundaryPoints.Count;
            m_BoundaryLineRenderer.SetPositions(BoundaryPoints.ToArray());
        }
    }