Beispiel #1
0
        static void ThreadLoadMethod(string path, Action <object> onComplete)
        {
            //UnityEngine.Debug.Log("load about to start" + path);
            if (!Exists(path))
            {
                onComplete.Invoke(null);
                return;
            }

            BinaryFormatter bf = new BinaryFormatter();
            //UnityEngine.Debug.Log("load started: " + path);
            FileStream file = File.Open(path, FileMode.Open);
            //UnityEngine.Debug.Log("load completed" + path);
            object obj = bf.Deserialize(file);

            file.Close();


            lock (MainThread.instance)
            {
                if (onComplete != null)
                {
                    MainThread.AddAction(delegate()
                    {
                        onComplete(obj);
                    });
                }
            }
        }
Beispiel #2
0
        static void ThreadSaveMethod(string path, object graph, UnityAction onComplete = null)
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(path, FileMode.OpenOrCreate);

            bf.Serialize(file, graph);
            file.Close();

            if (MainThread.instance == null)
            {
                UnityEngine.Debug.Log("MainThread.cs not in the scene.");
            }
            lock (MainThread.instance)
            {
                MainThread.AddAction(onComplete);
            }
        }
Beispiel #3
0
        static void ThreadLoadMethod(string path, UnityAction <object> onComplete)
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(path, FileMode.Open);
            object          obj  = bf.Deserialize(file);

            file.Close();

            lock (MainThread.instance)
            {
                if (onComplete != null)
                {
                    MainThread.AddAction(delegate()
                    {
                        onComplete(obj);
                    });
                }
            }
        }