コード例 #1
0
    // JSON



    void exportJSON()
    {
        string takeName     = aData.getCurrentTake().name;
        string saveJSONPath = EditorUtility.SaveFilePanel("Save JSON", "Assets/", takeName, "txt");

        if (saveJSONPath == "")
        {
            return;
        }

        // start serialization
        AnimatorTimeline.JSONTake j = new AnimatorTimeline.JSONTake();
        j.takeName = aData.getCurrentTake().name;
        List <AnimatorTimeline.JSONInit>   lsInits   = new List <AnimatorTimeline.JSONInit>();
        List <AnimatorTimeline.JSONAction> lsActions = new List <AnimatorTimeline.JSONAction>();

        foreach (AMTrack track in aData.getCurrentTake().trackValues)
        {
            if (dictTracks.ContainsKey(track.id) && dictTracks[track.id] == true)
            {
                // set initial values
                AnimatorTimeline.JSONInit init = track.getJSONInit();
                if (init != null)
                {
                    lsInits.Add(init);
                }
                // set actions
                foreach (AMAction action in track.cache)
                {
                    AnimatorTimeline.JSONAction a = action.getJSONAction(aData.getCurrentTake().frameRate);
                    if (a != null)
                    {
                        lsActions.Add(a);
                    }
                }
            }
        }
        j.inits   = lsInits.ToArray();
        j.actions = lsActions.ToArray();
        // serialize json
        string json = JsonWriter.Serialize(j);

        // write json to file
        File.WriteAllText(saveJSONPath, json);
        // refresh project directory
        AssetDatabase.Refresh();
        // refresh code
        refreshCode();
    }
コード例 #2
0
    // JSON
    void exportJSON()
    {
        string takeName = aData.getCurrentTake().name;
        string saveJSONPath = EditorUtility.SaveFilePanel("Save JSON","Assets/",takeName,"txt");
        if(saveJSONPath == "") return;

        // start serialization
        AnimatorTimeline.JSONTake j = new AnimatorTimeline.JSONTake();
        j.takeName = aData.getCurrentTake().name;
        List<AnimatorTimeline.JSONInit> lsInits = new List<AnimatorTimeline.JSONInit>();
        List<AnimatorTimeline.JSONAction> lsActions = new List<AnimatorTimeline.JSONAction>();
        foreach(AMTrack track in aData.getCurrentTake().trackValues) {
            if(dictTracks.ContainsKey(track.id) && dictTracks[track.id] == true) {
                // set initial values
                AnimatorTimeline.JSONInit init = track.getJSONInit();
                if(init != null) lsInits.Add(init);
                // set actions
                foreach(AMAction action in track.cache) {
                    AnimatorTimeline.JSONAction a = action.getJSONAction(aData.getCurrentTake().frameRate);
                    if(a != null) lsActions.Add(a);
                }
            }
        }
        j.inits = lsInits.ToArray();
        j.actions = lsActions.ToArray();
        // serialize json
        string json = JsonWriter.Serialize(j);
        // write json to file
        File.WriteAllText(saveJSONPath, json);
        // refresh project directory
        AssetDatabase.Refresh();
        // refresh code
        refreshCode();
    }