Exemplo n.º 1
0
        /// <summary>
        /// Pass in the game object's position to check if it's within
        /// the specified boundary space.
        /// </summary>
        /// <param name="gameObjectPosition">The position of the GameObject to check.</param>
        /// <param name="boundaryType">The type of the boundary. Use PlayArea for the inscribed rectangle or TrackedArea for the bounds containing the whole space.</param>
        /// <returns>True if the point is in the boundary type's bounds.</returns>
        public bool ContainsObject(Vector3 gameObjectPosition, UnityEngine.Experimental.XR.Boundary.Type boundaryType)
        {
            gameObjectPosition = CameraCache.Main.transform.parent.InverseTransformPoint(gameObjectPosition);

            if (gameObjectPosition.y < boundaryFloor || gameObjectPosition.y > boundaryHeight)
            {
                return(false);
            }

            if (boundaryType == UnityEngine.Experimental.XR.Boundary.Type.PlayArea)
            {
                if (inscribedRectangle == null || !inscribedRectangle.IsRectangleValid)
                {
                    return(false);
                }

                return(inscribedRectangle.IsPointInRectangleBounds(new Vector2(gameObjectPosition.x, gameObjectPosition.z)));
            }
            else if (boundaryType == UnityEngine.Experimental.XR.Boundary.Type.TrackedArea)
            {
                // Check if the supplied game object's position is within the bounds volume.
                return(EdgeHelpers.IsInside(boundaryGeometryEdges, new Vector2(gameObjectPosition.x, gameObjectPosition.z)));
            }

            return(false);
        }
Exemplo n.º 2
0
    public bool TryGetDimensions(out Vector3 dimensions, UnityEngine.Experimental.XR.Boundary.Type boundaryType = UnityEngine.Experimental.XR.Boundary.Type.PlayArea)
    {
        bool retVal = UnityEngine.Experimental.XR.Boundary.TryGetDimensions(out dimensions, boundaryType);

        TraceHelper.Log("TryGetDimensions " + (retVal ? "succeeded" : "failed"));
        return(retVal);
    }
Exemplo n.º 3
0
    public List <Vector3> TryGetGeometry(UnityEngine.Experimental.XR.Boundary.Type boundaryType = UnityEngine.Experimental.XR.Boundary.Type.PlayArea)
    {
        List <Vector3> geometry = new List <Vector3>();
        bool           retVal   = UnityEngine.Experimental.XR.Boundary.TryGetGeometry(geometry, boundaryType);

        TraceHelper.Log("TryGetGeometry " + (retVal ? "succeeded" : "failed"));
        if (retVal)
        {
            geometry.ForEach((v) => { TraceHelper.Log(v.ToString()); });
        }

        return(geometry);
    }
        public bool TryGetDimensions(out Vector3 dimensions, UnityEngine.Experimental.XR.Boundary.Type boundaryType = UnityEngine.Experimental.XR.Boundary.Type.PlayArea)
        {
            bool retVal = UnityEngine.Experimental.XR.Boundary.TryGetDimensions(out dimensions, boundaryType);

            if (retVal)
            {
                Debug.Log(string.Format("Dimensions for {0} are {1}", boundaryType, dimensions));
            }
            else
            {
                Debug.Log(string.Format("TryGetDimensions for {0} failed", boundaryType));
            }
            return(retVal);
        }
        public List <Vector3> TryGetGeometry(UnityEngine.Experimental.XR.Boundary.Type boundaryType = UnityEngine.Experimental.XR.Boundary.Type.PlayArea)
        {
            List <Vector3> geometry = new List <Vector3>();
            bool           retVal   = UnityEngine.Experimental.XR.Boundary.TryGetGeometry(geometry, boundaryType);

            if (retVal)
            {
                Debug.Log(string.Format("TryGetGeometry for {0} succeeded", boundaryType));
                geometry.ForEach((v) => { Debug.Log(v.ToString()); });
            }
            else
            {
                Debug.Log(string.Format("TryGetGeometry for {0} failed", boundaryType));
            }
            return(geometry);
        }