예제 #1
0
    private void SaveData()
    {
        foreach (Node _node in nodes)
        {
            TriggerNodeInfo script = sceneItems.Where(t => t.ID == _node.ID).First();
            GameObject      obj    = script.gameObject;
            obj.name = "Generated_Node_" + script.ID; //The name shows the node ID to make it easier.

            List <Vector2> v2Cons = null;

            if (_node.nodeCons.Count > 0)
            {
                v2Cons = new List <Vector2>();
                foreach (Connection con in _node.nodeCons)
                {
                    v2Cons.Add(new Vector2(con.inPoint.ID, con.outPoint.ID));
                }
            }

            script.SaveTriggerData(_node.rect, _node.ID, _node.title, _node.showAudio, _node.playedAudioClips, _node.delays, v2Cons, _node.pathType, _node.scrollViewVector, _node.worldPosition);
        }

        ConnectionsManager conManager = GetConnectionManager();

        List <ConnectionInfo> conList = new List <ConnectionInfo>();

        foreach (Connection con in connections)
        {
            conList.Add(new ConnectionInfo(con.inPoint.ID, con.outPoint.ID, con.connectionType));
        }

        conManager.SaveConnections(conList);

        //When the nodes and connections get saved, save the scene too to make sure everything is saved.
        string[] path = EditorSceneManager.GetActiveScene().path.Split(char.Parse("/"));
        path[path.Length - 1] = path[path.Length - 1];
        bool saveOK = EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene(), string.Join("/", path));

        Debug.Log("Saved the Nodes and the Scene " + (saveOK ? "Sucessfully" : "Error!"));
        nextSave = (float)EditorApplication.timeSinceStartup + saveTime;
    }