private static void InitializeOnLoad()
 {
     SerializedHistory.Load();
     s_oldSelection = Selection.objects;
     AssemblyReloadEvents.beforeAssemblyReload += BeforeAssemblyReload;
     Selection.selectionChanged += OnSelectionChanged;
     processEvent += OnProcessEvent;
 }
Пример #2
0
 private static void InitializeOnLoad()
 {
     SerializedHistory.Load();
     s_oldSelection = Selection.objects;
     AssemblyReloadEvents.beforeAssemblyReload += BeforeAssemblyReload;
     Selection.selectionChanged += OnSelectionChanged;
     EditorApplication.update   += WaitForUnityEditorToolbar;
     processEvent += OnProcessEvent;
 }
Пример #3
0
            public static void Save()
            {
                var history = new SerializedHistory
                {
                    backward = Serialize(s_backward),
                    forward  = Serialize(s_forward),
                };
                var json = JsonUtility.ToJson(history);

                EditorPrefs.SetString(Key, json);
                // Debug.Log("save: " + json);
            }
Пример #4
0
    public void FromJSON(string jsonText)
    {
        SerializedHistory input = JsonUtility.FromJson <SerializedHistory>(jsonText);

        this.scenario         = input.scenario;
        this.startingMap      = input.startingMap;
        this.currentTeamIndex = input.currentTeamIndex;

        this.moves = new List <object>(input.jsonTextOfMoves.Length);
        for (int n = 0; n < input.jsonTextOfMoves.Length; ++n)
        {
            System.Type type = System.Type.GetType(input.moveTypeNames[n]);
            object      move = JsonUtility.FromJson(input.jsonTextOfMoves[n], type);
            this.moves.Add(move);
        }
    }
Пример #5
0
    public string ToJSON()
    {
        SerializedHistory output = new SerializedHistory();

        output.scenario         = this.scenario;
        output.startingMap      = this.startingMap;
        output.currentTeamIndex = this.currentTeamIndex;

        output.moveTypeNames   = new string[this.moves.Count];
        output.jsonTextOfMoves = new string[this.moves.Count];
        for (int n = 0; n < this.moves.Count; ++n)
        {
            object o = this.moves[n];

            output.moveTypeNames[n] = o.GetType().FullName;

            if (o.GetType() == typeof(BattleMove.Move))
            {
                var move = (BattleMove.Move)o;
                output.jsonTextOfMoves[n] = JsonUtility.ToJson(move);
            }
            else if (o.GetType() == typeof(BattleMove.StandingFire))
            {
                var move = (BattleMove.StandingFire)o;
                output.jsonTextOfMoves[n] = JsonUtility.ToJson(move);
            }
            else if (o.GetType() == typeof(BattleMove.SetTarget))
            {
                var move = (BattleMove.SetTarget)o;
                output.jsonTextOfMoves[n] = JsonUtility.ToJson(move);
            }
            else
            {
                throw new UnityException();
            }
        }

        string jsonText = JsonUtility.ToJson(output, true);

        return(jsonText);
    }
Пример #6
0
 private static void BeforeAssemblyReload()
 {
     SerializedHistory.Save();
 }