static void ExportCSV()
    {
        if (m_timelineAsset == null || m_jsonAsset == null)
        {
            if (m_jsonAsset == null)
            {
                DisplayJsonFileDialog();
            }
            else
            {
                DisplayTimelineAsseteDialog();
            }
            return;
        }

        // we have to merge the lua function name.
        SingleSignalData json = SingleSignalData.CreateFromJSON(m_jsonAsset.text);

        UpdateTrackAsset();

        Dictionary <string, float> signals = new Dictionary <string, float>();

        foreach (var m in m_trackAsset.GetMarkers())
        {
            SignalEmitter se = m as SignalEmitter;

            if (string.IsNullOrEmpty(se.name) || se.name == "Signal Emitter")
            {
                EditorUtility.DisplayDialog("Name is empty", "You need to set up name as same as the SignalID.", "OK");
                return;
            }

            signals.Add(se.name, (float)se.time);
        }

        IOrderedEnumerable <KeyValuePair <string, float> > sorted = signals.OrderBy(pair => pair.Value);

        StringBuilder stringBuilder = new StringBuilder();

        stringBuilder.Append("Signal Enum,time,function names\n");
        foreach (KeyValuePair <string, float> pair in sorted)
        {
            string funcName = "";
            if (json.signalList.ContainsKey(pair.Key))
            {
                funcName = json.signalList[pair.Key].functionName;
            }
            //Debug.LogFormat("{0} {1}", pair.Key, pair.Value);
            stringBuilder.Append(pair.Key + "," + pair.Value + "," + funcName + "\n");
        }

        EditorUtils.WriteTextFile(CSV_FILEPATH, stringBuilder.ToString());
    }
    static void LoadSignalAssetsToTimeline()
    {
        if (m_timelineAsset == null)
        {
            return;
        }

        UpdateTrackAsset();

        foreach (var m in m_trackAsset.GetMarkers())
        {
            m_trackAsset.DeleteMarker(m);
        }

        List <ScriptableObject> list = new List <ScriptableObject>();
        string path = EditorUtils.DisplayFolderPanel("Load signals");

        if (path == "")
        {
            return;
        }
        EditorUtils.GetUnityObjectsOfTypeFromPath(path, list);

        Debug.Log(list.Count);

        TextAsset        jsonTxt = EditorUtils.GetJson(path);
        SingleSignalData json    = SingleSignalData.CreateFromJSON(jsonTxt.text);

        Debug.Log(json.signalList.Count);
        for (int i = 0; i < list.Count; i++)
        {
            SignalAsset signal = list[i] as SignalAsset;
            SignalData  data   = json.signalList[signal.name];
            //Debug.Log(data.time);

            SignalEmitter emitter = m_trackAsset.CreateMarker <SignalEmitter>(data.time);
            emitter.name  = signal.name;
            emitter.asset = signal;
        }
    }
Example #3
0
 public void LoadJSON()
 {
     m_signalData = SingleSignalData.CreateFromJSON(m_jsonAsset.text);
 }