static void ThreadLoadMethod(string path, Action <object> onComplete) { //UnityEngine.Debug.Log("load about to start" + path); if (!Exists(path)) { onComplete.Invoke(null); return; } object obj = null; BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(path, FileMode.Open); try { obj = bf.Deserialize(file); } catch (Exception e) { UnityEngine.Debug.LogError("Failed to deserialize the following file:\n" + path + "\n\nError:\n" + e.Message); } file.Close(); if (onComplete != null) { MainThread.AddActionFromThread(delegate() { onComplete(obj); }); } }
static void ThreadSaveMethod(string path, object graph, Action onComplete = null) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(path, FileMode.OpenOrCreate); bf.Serialize(file, graph); file.Close(); MainThread.AddActionFromThread(onComplete); }
public static void DisplayMessageFromThread(string message, TweenCallback onComplete = null) { MainThread.AddActionFromThread(() => DisplayMessage(message, onComplete)); }