示例#1
0
    void OnEnable()
    {
        snd = GetComponent <SceneNodeData>();

        sceneNodes  = RetrieveSceneNodes();
        objectNodes = RetrieveObjectsNodes(); //for debug

        quadTree = new QuadTree <SceneNode>(mapDensity, mapMinWidth, new Rect(-mapSize / 2, -mapSize / 2, mapSize, mapSize));
        foreach (SceneNode to in sceneNodes)
        {
            quadTree.Insert(to);
        }

        objParent      = new GameObject();
        objParent.name = "QuadTree";
    }
    public static void ArrangeObj()
    {
        GameObject go = Selection.activeGameObject;

        if (go == null)
        {
            return;
        }

        CheckChildrenNameUnique();

        GameObject root = new GameObject();

        root.name = go.name + "_QuadTree";

        GameObject tree = new GameObject();

        tree.transform.parent = root.transform;
        tree.name             = "QuadTreeInfo";
        tree.AddComponent <SceneDynLoadManager>();
        tree.AddComponent <QuadTreeSceneManager>();
        tree.AddComponent <SceneAssetsManager>();

        SceneNodeData snd = tree.AddComponent <SceneNodeData>();

        snd.mapSize     = mapSize;
        snd.mapDensity  = mapDensity;
        snd.mapMinWidth = mapMinWidth;
        snd.nodeDepth   = nodeDepth;
        snd.layerMask   = layerMask.value;
        snd.Save(go.transform);

        GameObject objs = new GameObject();

        objs.transform.parent = root.transform;
        objs.name             = "Objs";
        ArrangeOneObj(snd.sceneTree, objs.transform);

        //Base
        SaveLightmapData(go);
        go.name             = "Base";
        go.transform.parent = tree.transform;

        Selection.activeGameObject = root;
    }