コード例 #1
0
    GenericMenu.MenuFunction OnNodeCreate(Type t)
    {
        if (m_curTree == null)
        {
            return(null);
        }

        if (m_curTree.Root != null && !m_treeMap.ContainsKey(m_selectRow))
        {
            return(null);
        }

        GenericMenu.MenuFunction func;
        func = delegate(){
            BNode newNode = Activator.CreateInstance(t) as BNode;
            if (m_curTree.Root == null)
            {
                m_curTree.SetRoot(newNode);
            }
            else
            {
                BNode parent = m_treeMap[m_selectRow];
                parent.AddNode(newNode);
            }
            Repaint();
        };
        return(func);
    }
コード例 #2
0
ファイル: BehavTreeMagager.cs プロジェクト: itol925/Unity3d
    BehavTree ReadTreeFromJson(string path)
    {
        string   jsonText = File.ReadAllText(path);
        JsonData json     = JsonMapper.ToObject(jsonText);

        BNode     root = ReadJsonNode(json);
        FileInfo  file = new FileInfo(path);
        BehavTree tree = new BehavTree(file.Name);

        tree.SetRoot(root);
        return(tree);
    }