Ejemplo n.º 1
0
    public void Save()
    {
        JsonTestClass.MusicalFile musicFile = new JsonTestClass.MusicalFile();
        musicFile.numberNote  = partition.Count;
        musicFile.musicalNote = new JsonTestClass.MusicalNote[partition.Count];


        for (int i = 0; i < partition.Count; i++)
        {
            if (partition [i].NoteToPlay)
            {
                musicFile.musicalNote[i] = new JsonTestClass.MusicalNote(partition [i].NoteToPlay.getNoteName(), partition [i].NoteToPlay.Octave - 1, partition [i].nbFourth * 0.25f);
            }
            else
            {
                musicFile.musicalNote[i] = new JsonTestClass.MusicalNote(0, 10, partition [i].nbFourth * 0.25f);
            }
        }



        String        ressourcePath = Path.Combine(Application.dataPath, "Resources");                   // Get Path to game resources folder
        DirectoryInfo di            = new DirectoryInfo(Path.Combine(ressourcePath, "StreamingAssets")); // Get Path to Streaming assets

        int numberFiles = CreateFiles.DirCount(di) / 2;

        String filePath = Path.Combine("StreamingAssets", "Comp" + numberFiles + ".json"); // Get Path to file in resources folder
        String realPath = Path.Combine(ressourcePath, filePath);                           // Get Real Path

        JsonTestClass.SaveJSONToFile(JsonTestClass.MapToJSON(musicFile), realPath);
    }
Ejemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        firstIndex = 0;
        files      = new List <GameObject>();
        int nbShown = 0;

        String        ressourcePath = Path.Combine(Application.dataPath, "Resources");                   // Get Path to game resources folder
        DirectoryInfo di            = new DirectoryInfo(Path.Combine(ressourcePath, "StreamingAssets")); // Get Path to Streaming assets

        int numberFiles = CreateFiles.DirCount(di) / 2;

        FileInfo[] fis = di.GetFiles();
        for (int i = 0; i < numberFiles; i++)
        {
            GameObject newObj = Instantiate(fileObject, this.transform, false);
            newObj.transform.localPosition = new Vector3(x, y, z + i);
            String fileName = fis [2 * i].Name;
            String realName = fileName.Substring(0, (fileName.Length - 5));
            newObj.GetComponent <MusicFileScript> ().fileName            = realName;
            newObj.GetComponent <LevelSelectScript> ().fileName          = realName;
            newObj.transform.GetChild(0).GetComponent <TextMesh> ().text = realName;
            if (nbShown < nbFileShown)
            {
                nbShown++;
            }
            else
            {
                newObj.SetActive(false);
            }
            files.Add(newObj);
        }
    }