Exemplo n.º 1
0
    public void updateFolder(string newFolder)
    {
        currentFolder = newFolder;

        windows.RemoveRange(1, windows.Count - 1);

        int x = 25, y = 55;
        int nodesInRow = 0;


        GameObject            lwoGO;
        ConversationGenerator lwo;

        //NodeEditor editor = EditorWindow.GetWindow<NodeEditor>();

        //nodeEditorGarbageGO = new GameObject ();
        //nodeEditorGarbageGO.name = "_editorGarbage";


        //windows.Add (folderChooser);

        string path = Application.dataPath + "/Resources/Prefabs/NodeEditorObjects/" + currentFolder;

        DirectoryInfo info = new DirectoryInfo(path);

        FileInfo[] fileInfo = info.GetFiles();

        foreach (FileInfo file in fileInfo)
        {
            string fname = file.Name;
            if (fname.EndsWith(".prefab"))
            {
                string     nodeName = fname.Substring(0, fname.Length - ".prefab".Length);
                ObjectNode newNode  = ObjectNode.CreateInstance <ObjectNode> ();
                newNode.currentFolder = currentFolder;
                newNode.windowTitle   = nodeName;
                newNode.windowRect    = new Rect(x, y, 180, 240);

                lwoGO = Instantiate(Resources.Load("Prefabs/NodeEditorObjects/" + currentFolder + "/" + nodeName, typeof(GameObject))) as GameObject;
                //lwoGO.transform.parent = nodeEditorGarbageGO.transform;
                lwo = lwoGO.GetComponent <ConversationGenerator> ();
                newNode.theObject = lwoGO;
                newNode.theWO     = lwo;
                if (newNode.theWO.isRoot)
                {
                    windows.Add(newNode);

                    //newNode.events = new List<string> ();
                    //string[] evNames = lwo.getEvents ();
                    //for (int i = 0; i < evNames.Length; ++i) {
                    //	newNode.addEvent (evNames [i]);
                    //}
                    ++nodesInRow;
                    x += 180 + 15;
                    if (nodesInRow >= maxNodesPerRow)
                    {
                        x          = 15;
                        y         += 180 + 15;
                        nodesInRow = 0;
                    }
                }                 // end of if isRoot
            }
        }
    }