public static void OnConnectionCallbackInternal(MLResult.Code result, [MarshalAs(UnmanagedType.LPStr)] string connectionName, IntPtr userData)
        {
            if (MLResult.IsOK(result))
            {
                MLAppConnect.RegisterEventCallback(connectionName);
            }

            MLThreadDispatch.Call(result, connectionName, OnConnection);
        }
        /// <summary>
        /// Reads all stored persistent bindings.
        /// Each stored binding will contain a PCF object with a CFUID.
        /// Use that stored CFUID to see if the PCF exists in this session, if it does then the stored binding can be regained.
        /// If the binding is regained correctly then the persistent content will retain it's pose from the last known launch.
        /// </summary>
        private void RegainAllStoredBindings()
        {
            #if PLATFORM_LUMIN
            TransformBinding.storage.LoadFromFile();

            List <TransformBinding> allBindings = TransformBinding.storage.Bindings;

            List <TransformBinding> deleteBindings = new List <TransformBinding>();

            foreach (TransformBinding storedBinding in allBindings)
            {
                // Try to find the PCF with the stored CFUID.
                MLResult result = MLPersistentCoordinateFrames.FindPCFByCFUID(storedBinding.PCF.CFUID, (MLResult.Code resultCode, MLPersistentCoordinateFrames.PCF pcf) =>
                {
                    if (pcf != null && MLResult.IsOK(pcf.CurrentResultCode))
                    {
                        GameObject gameObj = Instantiate(_content, Vector3.zero, Quaternion.identity);
                        PersistentBall persistentContent       = gameObj.GetComponent <PersistentBall>();
                        persistentContent.BallTransformBinding = storedBinding;
                        persistentContent.BallTransformBinding.Bind(pcf, gameObj.transform, true);
                        ContentTap contentTap    = persistentContent.GetComponent <ContentTap>();
                        contentTap.OnContentTap += OnContentDestroy;
                        ++numPersistentContentRegained;
                        _persistentContentMap.Add(persistentContent, "Regained");
                    }
                    else
                    {
                        deleteBindings.Add(storedBinding);
                    }
                });
            }

            foreach (TransformBinding storedBinding in deleteBindings)
            {
                storedBinding.UnBind();
            }

            bindingsLoaded = true;
            #endif
        }
        /// <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));
                }
            }
        }