示例#1
0
        /// <summary>
        /// Finds the closest pcf for this persistent point.
        /// </summary>
        void BindToAllPCFs()
        {
            _state = State.BindToAllPCFs;
            string suffix = "";
            int    count  = 0;

            // In the loop below we try to associate the persitent point with not only
            // the closest but all pcfs in the surrounding. This will increase the probablilty
            // of restoration on reboots. It's costly in terms of disk space so we will limit it to
            // a max
            foreach (MLPCF pcf in _allPCFs)
            {
                string objectName   = gameObject.name + suffix;
                var    returnResult = MLPersistentCoordinateFrames.GetPCFPosition(pcf, (result, returnPCF) =>
                {
                    if (result.IsOk && pcf.CurrentResult == MLResultCode.Ok)
                    {
                        Debug.Log("binding to PCF: " + pcf.CFUID);

                        Binding = MLContentBinder.BindToPCF(objectName, gameObject, pcf);
                        MLPersistentStore.Save(Binding);
                    }
                    else
                    {
                        Debug.LogWarningFormat("Failed to find the position for PCF {0}", returnPCF.CFUID);
                    }
                });
                if (!returnResult.IsOk)
                {
                    Debug.LogError("Failed to GetPCF");
                    break;
                }
                suffix = "-" + count;
                count++;
            }

            _state = State.BindingComplete;
        }
 /// <summary>
 /// Tries the showing all PCF.
 /// </summary>
 /// <param name="pcfList">Pcf list.</param>
 void TryShowingAllPCFs(List <MLPCF> pcfList)
 {
     foreach (MLPCF pcf in pcfList)
     {
         if (pcf.CurrentResult == MLResultCode.Pending)
         {
             MLPersistentCoordinateFrames.GetPCFPosition(pcf, (r, p) =>
             {
                 if (r.IsOk)
                 {
                     AddPCFObject(p);
                 }
                 else
                 {
                     SetError("failed to get position for pcf : " + p);
                 }
             });
         }
         else
         {
             AddPCFObject(pcf);
         }
     }
 }