Esempio n. 1
0
    public static void FillTestData(int days)
    {
        // load random textures form resources
        Texture2D[] textures = Resources.LoadAll <Texture2D>("RandomTextures");

        // int days = 1;
        // stay today date empty to use
        DateTime date = DateTime.Now.AddDays(-days).Date;

        Debug.Log("Fixed start date: " + date.ToString("dd/MM/yyyy"));

        JSONObject notesListObject = new JSONObject();

        for (int i = 0; i < days; i++)
        {
            // don't fill each day
            if (Random.Range(0f, 1f) > 0.5f)
            {
                continue;
            }

            int maxNotes = Random.Range(1, 5);
            for (int j = 0; j < maxNotes; j++)
            {
                NoteData noteData = new NoteData(date);
                noteData.noteText = _notesTemplates[Random.Range(0, _notesTemplates.Length)];
                notesListObject.Add(noteData.FormatToJson());
            }

            // add a single day
            date = date.AddDays(1);
        }

        WriteToFile(_localPath, notesListObject.Print(true));
        Debug.LogWarning($"Random notes generated for {days} days");
    }