示例#1
0
 /// <summary>
 /// Handles when an array of found objects is returned by the API.
 /// </summary>
 /// <param name="result">MLResult of the query.</param>
 /// <param name="foundObjects">Array of found objects returned by the query.</param>
 private void HandleOnFoundObjects(MLResult result, MLFoundObjects.FoundObject[] foundObjects)
 {
     if (result.IsOk)
     {
         OnFoundObjects?.Invoke(foundObjects);
     }
     else
     {
         Debug.LogFormat("MLFoundObjects failed to find any objects. Reason: {0}", MLResult.CodeToString(result.Result));
     }
 }
        /// <summary>
        /// Every _secondsToRequeue, this coroutine will attempt to find all pcfs and queue them all for updates.
        /// </summary>
        private IEnumerator ContinuouslyFindAllPCFs()
        {
            // Uses a while loop so that we can catch PCFs being created during runtime.
            while (true)
            {
                yield return(new WaitForEndOfFrame());

                if (IsVisualizing)
                {
                    #if PLATFORM_LUMIN
                    // MLPersistentCoordinateFrames.FindAllPCFs() returns the PCFs found in the current map.
                    // Calling this function is expensive and is only called repeatedly for demonstration purposes.
                    // This function will create new pcfs during a new headpose session.
                    MLPersistentCoordinateFrames.FindAllPCFs((MLResult.Code resultCode, List <MLPersistentCoordinateFrames.PCF> allPCFs) =>
                    {
                        if (!MLResult.IsOK(resultCode))
                        {
                            if (resultCode == MLResult.Code.PassableWorldLowMapQuality || resultCode == MLResult.Code.PassableWorldUnableToLocalize)
                            {
                                Debug.LogWarningFormat("Map quality not sufficient enough for PCFVisualizer to find all pcfs. Reason: {0}", MLResult.CodeToString(resultCode));
                            }
                            else
                            {
                                Debug.LogErrorFormat("Error: PCFVisualizer failed to find all PCFs because MLPersistentCoordinateFrames failed to get all PCFs. Reason: {0}", MLResult.CodeToString(resultCode));
                            }
                        }
                        else
                        {
                            OnFindAllPCFs?.Invoke(allPCFs);
                        }
                    });
                    #endif

                    yield return(new WaitForSeconds(_secondsToRequeue));
                }
            }
        }