Advertisement
Guest User

Untitled

a guest
Dec 11th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.05 KB | None | 0 0
  1. namespace Evoluon.Editeur
  2. {
  3.   [InitializeOnLoad]
  4.   public class EditorEvents
  5.   {
  6.     static EditorEvents()
  7.     {
  8.       EditorPlayMode.PlayModeChanged -= ReplaceDatasByRuntime;
  9.       EditorPlayMode.PlayModeChanged += ReplaceDatasByRuntime;
  10.     }
  11.  
  12.     private static void ReplaceDatasByRuntime(PlayModeState currentMode, PlayModeState changedMode)
  13.     {
  14.       if (changedMode == PlayModeState.Stopped)
  15.       {
  16.         WorldManager wm = Object.FindObjectOfType<WorldManager>();
  17.         Debug.Log("Count saves : " + wm.saves.Count);
  18.         ThreadPool.QueueUserWorkItem(state => ReplaceDatas(wm));
  19.       }
  20.     }
  21.  
  22.     public static void ReplaceDatas(WorldManager wm)
  23.     {
  24.       Thread.Sleep(2000);
  25.  
  26.       foreach (Save s in wm.saves)
  27.       {
  28.         Debug.Log(s.datas.GetType());
  29.         Debug.Log("Saved data " + ((TurbuDatas)s.datas).octave);
  30.  
  31.         EditeurZone zone = wm._zonesT.Where(p => p == s.zone).Single();
  32.         Debug.Log("Reel data " + zone.Turbu.datas.octave);
  33.         s.zone.Turbu.datas = (TurbuDatas)s.datas;
  34.       }
  35.     }
  36.   }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement