Пример #1
0
    private void InitMetaData()
    {
        var       rootText  = Resources.Load <TextAsset>("meta/root" + SceneManager.GetActiveScene().name);
        var       docStream = new StringReader(rootText.text);
        RootGraph root      = RootGraph.Construct(docStream);

        foreach (var clip in root.Clips)
        {
            //load clip
            var      clipText      = Resources.Load <TextAsset>("meta/" + clip.Path);
            var      clipDocStream = new StringReader(clipText.text);
            ClipTree clipGraph     = ClipTree.Construct(clipDocStream);
            var      ser           = new YamlDotNet.Serialization.Serializer();

            clipGraphs.Add(clip.Name, clipGraph);
            var midiFile = Resources.Load <TextAsset>("clips/" + clipGraph.Midi);
            Debug.Log(clipGraph.Midi);

            AudioSource audioSource = AddAudioSourceToScene(clipGraph.Audio);

            //parse midi
            Midi midi = new MidiParser().Parse(midiFile.bytes);
            //debug
            Debug.Log(midi.Tracks[2].Bpm);
            foreach (var msg in midi.Tracks[2].Messages)
            {
                Debug.Log(msg);
            }
            Debug.Log(ser.Serialize(clipGraph));
            clips.Add(clip.Name, new Assets.Core.Clip(audioSource, midi));
        }
        foreach (var graph in root.Scriptgraphs)
        {
            var graphText = Resources.Load <TextAsset>("meta/" + graph.Path);
            Debug.Log(graphText);
            var        graphDocStream = new StringReader(graphText.text);
            ScriptTree scriptGraph    = ScriptTree.Construct(graphDocStream);
            var        ser            = new YamlDotNet.Serialization.Serializer();

            scriptGraphs.Add(graph.Name, scriptGraph);
            Debug.Log("Constructed a script graph : " + graph.Name);
            Debug.Log(ser.Serialize(scriptGraph));
        }
    }
Пример #2
0
        protected void Save()
        {
            ScriptTree tree = ScriptTree.Construct(this);

            Meta.SaveScripts(currScriptName, tree);
        }