Ejemplo n.º 1
0
        /// <summary>
        // Raycast using just a transform reference
        /// </summary>
        public static MLResult Raycast(Transform transform, MLRaycast.OnRaycatResultDelegate callback)
        {
            _parameters.Position              = transform.position;
            _parameters.Direction             = transform.forward;
            _parameters.UpVector              = transform.up;
            _parameters.Width                 = 1;
            _parameters.Height                = 1;
            _parameters.HorizontalFovDegrees  = 0;
            _parameters.CollideWithUnobserved = false;

            return(Raycast(_parameters, callback));
        }
Ejemplo n.º 2
0
        /// <summary>
        // Raycast using full QueryParams object
        /// </summary>
        public static MLResult Raycast(MLRaycast.QueryParams parameters, MLRaycast.OnRaycatResultDelegate callback)
        {
            if (MLRaycast.IsStarted)
            {
                _result = MLRaycast.Raycast(parameters, callback);

                if (!_result.IsOk)
                {
                    Debug.LogErrorFormat("Error: MLRaycastStarterKit.Raycast failed. Reason: {0}", _result);
                }
            }

            else
            {
                Debug.LogError("Error: MLRaycastStarterKit.Raycast failed because MLRaycast was not started.");
                _result = MLResult.Create(MLResult.Code.UnspecifiedFailure, "MLRaycast was not started");
            }

            return(_result);
        }
Ejemplo n.º 3
0
        /// <summary>
        // Raycast using just rayOrigin, rayDirection, and rayUpwardVector
        /// </summary>
        public static MLResult Raycast(Vector3 rayOrigin, Vector3 rayDirection, Vector3 rayUpwardDirection, MLRaycast.OnRaycatResultDelegate callback)
        {
            _parameters.Position              = rayOrigin;
            _parameters.Direction             = rayDirection;
            _parameters.UpVector              = rayUpwardDirection;
            _parameters.Width                 = 1;
            _parameters.Height                = 1;
            _parameters.HorizontalFovDegrees  = 0;
            _parameters.CollideWithUnobserved = false;

            return(Raycast(_parameters, callback));
        }