예제 #1
0
    public void SaveToJSON()
    {
        string fileName = DateTime.Now.ToString("yyyy-MM-dd--HH-mm-ss") + ".txt";
        string path     = Application.dataPath;

        Debug.Log(path);

        DirectoryInfo di = new DirectoryInfo(Path.Combine(path, "Games"));

        if (!di.Exists)
        {
            di.Create();
        }

        TableEditorDataHolder tedh = GameObject.FindGameObjectWithTag("TableEditorDataHolder").GetComponent <TableEditorDataHolder>();

        tables = tedh.getTables();

        data.tables = tedh.getTables();
        data.loadCards();


        Debug.Log(Path.Combine(di.FullName, fileName));
        Debug.Log("Mentve");
        var sr = File.CreateText(Path.Combine(di.FullName, fileName));
        //sr.WriteLine(JsonUtility.ToJson(tables));
        JsonSerializerSettings settings = new JsonSerializerSettings {
            TypeNameHandling = TypeNameHandling.All
        };

        // SerializableObjects so = new SerializableObjects();
        //so.loadForSave();
        // sr.WriteLine(JsonConvert.SerializeObject(CommandProcessor.Instance.getStackToSave(), settings));
        // GameSaveDataHolder gsdh = GameObject.FindGameObjectWithTag("GameSaveDataHolder").GetComponent<GameSaveDataHolder>();
        sr.WriteLine(JsonConvert.SerializeObject(data, settings));
        sr.Close();
    }
예제 #2
0
    void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
            // tabledata = GameObject.FindGameObjectWithTag("TableEditorDataHolder").GetComponent<TableEditorDataHolder>();
            // players = GameObject.FindGameObjectsWithTag("Player").GetComponent<Player>();
            TableEditorDataHolder tedh = GameObject.FindGameObjectWithTag("TableEditorDataHolder").GetComponent <TableEditorDataHolder>();
            tables = tedh.getTables();


            DontDestroyOnLoad(gameObject);
        }
        else
        {
            DestroyImmediate(gameObject);
        }
    }