Exemple #1
0
        // Stream
        #region
        public static bool MarkedFromStream(Stream stream)
        {
#if DBG
            string status = "Began";
#endif

            try
            {
                if (stream.Length == 0)
                {
#if DBG
                    Log("Save stream is empty");
#endif
                    return(false);
                }

                var data = Load.ObjectFromStream <Dictionary <int, string> >(stream);
#if DBG
                status = "Loaded marked from stream";
#endif
                var markers = UnityObject.FindObjectsOfType <FSMarker>();

                if (OnBeganLoadingMarked != null)
                {
                    OnBeganLoadingMarked(data);
                }

                for (int i = 0; i < markers.Length; i++)
                {
                    var    marked = markers[i];
                    int    id     = marked.GetPersistentId();
                    string serializedState;
                    if (!data.TryGetValue(id, out serializedState))
                    {
                        continue;
                    }
#if DBG
                    status = "Loading " + marked.name;
#endif
                    var bytes = serializedState.GetBytes();
                    using (var memory = new MemoryStream(bytes))
                        Load.GameObjectFromStream(memory, marked.gameObject);
                }

                if (OnFinishedLoadingMarked != null)
                {
                    OnFinishedLoadingMarked(data);
                }

                return(true);
            }
            catch (Exception e)
            {
#if DBG
                Log(string.Format("Error ({0}) {1}", status, e.Message));
#else
                Log("Error loading: " + e.Message);
#endif
                return(false);
            }
        }
 public static void LoadFromMemory(this Component into, byte[] bytes)
 {
     Load.ComponentFromMemory(bytes, into);
 }
 public static void LoadFromMemory(this GameObject into, byte[] bytes)
 {
     Load.GameObjectFromMemory(bytes, into);
 }
 public static void LoadFromStream(this GameObject into, Stream stream)
 {
     Load.GameObjectFromStream(stream, into);
 }
 public static void LoadHierarchyFromStream(this GameObject into, Stream stream)
 {
     Load.HierarchyFromStream(stream, into);
 }