Exemple #1
0
        /// <summary>
        /// Tries to restore the binding or find closest PCF.
        /// </summary>
        void RestoreBinding(string objId)
        {
            if (MLPersistentStore.Contains(objId))
            {
                MLContentBinding binding;

                MLResult result = MLPersistentStore.Load(objId, out binding);
                if (!result.IsOk)
                {
                    SetError(new MLResult(result.Code,
                                          string.Format("Error: MLPersistentPoint failed to load binding. Reason: {0}", result)));
                    SetComplete(false);
                }
                else
                {
                    Binding            = binding;
                    Binding.GameObject = this.gameObject;
                    MLContentBinder.Restore(Binding, HandleBindingRestore);
                }
            }
            else
            {
                StartCoroutine(BindToClosestPCF());
            }
        }
Exemple #2
0
        /// <summary>
        /// Tries to restore the binding from persistent storage and PCF system
        /// </summary>
        IEnumerator RestoreBinding(string objId)
        {
            _state = State.RestoreBinding;

            if (MLPersistentStore.Contains(objId))
            {
                MLContentBinding binding;

                MLResult result = MLPersistentStore.Load(objId, out binding);
                if (!result.IsOk)
                {
                    SetError(result);
                    _state = State.BindingComplete;
                }
                else
                {
                    Binding = binding;
                    Debug.Log("binding result : " + Binding.PCF.CurrentResult);
                    Binding.GameObject = this.gameObject;
                    MLContentBinder.Restore(Binding, HandleBindingRestore);
                }
            }
            else
            {
                BindToAllPCFs();
            }

            while (_state != State.BindingComplete)
            {
                yield return(null);
            }
            yield break;
        }
        /// <summary>
        /// Tries to restore the binding
        /// </summary>
        void RestoreBinding()
        {
            MLContentBinding binding;

            MLResult result = MLPersistentStore.Load(UniqueId, out binding);

            if (!result.IsOk)
            {
                Debug.LogErrorFormat("Error: MLPersistentBehavior failed to load binding. Reason: {0}", result);
                NotifyChangeOfStatus(Status.RESTORE_FAILED, result);
            }
            else
            {
                Binding            = binding;
                Binding.GameObject = this.gameObject;
                MLContentBinder.Restore(Binding, HandleBindingRestore);
            }
        }
        /// <summary>
        /// Try to restore after a delay
        /// </summary>
        /// <returns>IEnumerator for delay</returns>
        IEnumerator TryRestore()
        {
            yield return(new WaitForSeconds(RetryDelayInSeconds));

            MLContentBinder.Restore(Binding, HandleBindingRestore);
        }