Exemplo n.º 1
0
    /// <summary>
    /// Saves word list to a file
    /// </summary>
    private void SaveWordToFile()
    {
        // Creates a new JsonWords object
        JsonWords fileWords = new JsonWords();

        // Assign the list in the object to our word list
        fileWords.words = m_WordList;

        // Serializes the object to a string
        string fileContent = JsonConvert.SerializeObject(fileWords, Formatting.Indented);

        // Writes the serialized data to the file
        File.WriteAllText(WORD_FILE_NAME, fileContent);
    }
Exemplo n.º 2
0
    /// <summary>
    /// Loads the words from a file and sets m_WordList to the loaded list
    /// </summary>
    private void LoadWordsFromFile()
    {
        // Check if the file exists
        if (File.Exists(WORD_FILE_NAME))
        {
            // Load the content of the file
            string fileContent = File.ReadAllText(WORD_FILE_NAME);

            // Deserializes the content from the file and creates a object
            JsonWords fileWords = JsonConvert.DeserializeObject <JsonWords>(fileContent);

            // Assign the loaded list to the m_WordList variables
            m_WordList = fileWords.words;
        }
    }
Exemplo n.º 3
0
    void Start()
    {
        words = JsonUtility.FromJson <JsonWords>(jsonFile.text);

        Debug.Log(words.letters9[10]);
    }