Пример #1
0
        /// <summary>
        /// Instantiates a new object with MLPersistentPoint. The MLPersistentPoint is
        /// responsible for restoring and saving itself.
        /// </summary>
        void CreateObject()
        {
            Vector3 position = Camera.main.transform.position + Camera.main.transform.forward * UnityEngine.Random.Range(1.5f, 6.0f);
            var     gameObj  = Instantiate(_prefab, position, UnityEngine.Random.rotation);

            gameObj.name = Guid.NewGuid().ToString();
            MLPersistentPoint persistentPointBehavior = gameObj.GetComponent <MLPersistentPoint>();

            persistentPointBehavior.OnComplete += HandleContentRestoreComplete;
            persistentPointBehavior.OnError    += HandleContentRestoreError;
            _persistentPoints.Add(persistentPointBehavior);
        }
Пример #2
0
        /// <summary>
        /// Reads all stored game object ids.
        /// </summary>
        void ReadAllStoredObjects()
        {
            List <MLContentBinding> allBindings = MLPersistentStore.AllBindings;

            foreach (MLContentBinding binding in allBindings)
            {
                GameObject gameObj = Instantiate(_prefab, Vector3.zero, Quaternion.identity);
                gameObj.name = binding.ObjectId;
                MLPersistentPoint persistentPointBehavior = gameObj.GetComponent <MLPersistentPoint>();
                persistentPointBehavior.OnComplete += HandleContentRestoreComplete;
                persistentPointBehavior.OnError    += HandleContentRestoreError;
                _persistentPoints.Add(persistentPointBehavior);
            }
        }