コード例 #1
0
    /**
     * Find the children game objects in the scene graph at the addresses from the view model's scene graph.
     * @param	rootAddress	The root will not be in the graph.  The root's children will be the values of the top-level hash.
     */
    public static Dictionary <string, GameObjectTree> FindGraph(Dictionary <string, object> graph, GameObject root)
    {
        Dictionary <string, GameObjectTree> sceneGraph = new Dictionary <string, GameObjectTree>();

        foreach (KeyValuePair <string, object> item in graph)
        {
            string         name  = item.Key;
            GameObject     child = ViewUtil.GetChild(root, name);
            GameObjectTree node  = new GameObjectTree(child);
            sceneGraph[name] = node;
            if (null == child)
            {
                Debug.Log("Expected child at " + name);
            }
            else if (item.Value is Dictionary <string, object> )
            {
                Dictionary <string, object> subGraph = (Dictionary <string, object>)item.Value;
                sceneGraph[item.Key].children = FindGraph(subGraph, child);
            }
        }
        return(sceneGraph);
    }