/// <summary>
        // Raycast using full QueryParams object
        /// </summary>
        public static MLResult Raycast(MLRaycast.QueryParams parameters, MLRaycast.OnRaycastResultDelegate callback)
        {
            _result = MLRaycast.Raycast(parameters, callback);

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

            return(_result);
        }
Example #2
0
 // Update is called once per frame
 void Update()
 {
     // Create a raycast parameters variable
     MLRaycast.QueryParams _raycastParams = new MLRaycast.QueryParams
     {
         // Update the parameters with our Camera's transform
         Position  = ctransform.position,
         Direction = ctransform.forward,
         UpVector  = ctransform.up,
         // Provide a size of our raycasting array (1x1)
         Width  = 1,
         Height = 1
     };
     // Feed our modified raycast parameters and handler to our raycast request
     MLRaycast.Raycast(_raycastParams, HandleOnReceiveRaycast);
 }
Example #3
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);
        }
 private void startRayCasting()
 {
     this.queryParams = new MLRaycast.QueryParams()
     {
         CollideWithUnobserved = false,
         Direction = transform.forward,
         Height = 1,
         HorizontalFovDegrees = 0,
         Position = transform.position,
         UpVector = transform.up,
         Width = 1
     };
     MLResult raycastResult = MLRaycast.Raycast(queryParams, OnRaycastResult);
     switch (raycastResult.Result)
     {
         case MLResult.Code.Ok:
             //
             break;
         case MLResult.Code.InvalidParam:
             throw new System.NotImplementedException();
         case MLResult.Code.PrivilegeDenied:
             throw new System.NotImplementedException();
     }
 }