void Start()
    {
        DMComponent root        = new DMComposite("Root");
        DMLeaf      leaf1       = new DMLeaf("GameObject (2)");
        DMLeaf      leaf2       = new DMLeaf("GameObject (3)");
        DMComposite gameObject1 = new DMComposite("GameObject (1)");

        root.AddChild(gameObject1);
        root.AddChild(leaf2);
        gameObject1.AddChild(leaf1);
    }
Пример #2
0
    void Start()
    {
        DMComposite compositeRoot = new DMComposite("CompositeRoot");
        DMLeaf      leaf1         = new DMLeaf("Leaf1");
        DMComposite composite     = new DMComposite("Composite");
        DMLeaf      leaf2         = new DMLeaf("Leaf2");

        compositeRoot.AddChild(leaf1);
        compositeRoot.AddChild(composite);
        compositeRoot.AddChild(leaf2);

        DMLeaf leaf2_1 = new DMLeaf("Leaf2-1");
        DMLeaf leaf2_2 = new DMLeaf("Leaf2-2");

        composite.AddChild(leaf2_1);
        composite.AddChild(leaf2_2);

        DeepReadComposite(compositeRoot); //遍历
    }
    void Start()
    {
        DMComposite root = new DMComposite("Root");

        DMLeaf      leaf1       = new DMLeaf("GameObject");
        DMLeaf      leaf2       = new DMLeaf("GameObject (2)");
        DMComposite gameObject1 = new DMComposite("GameObject (1)");

        root.AddChild(leaf1);
        root.AddChild(gameObject1);
        root.AddChild(leaf2);

        DMLeaf child1 = new DMLeaf("GameObject");
        DMLeaf child2 = new DMLeaf("GameObject (1)");

        gameObject1.AddChild(child1);
        gameObject1.AddChild(child2);

        ReadComponent(root);
    }