Exemplo n.º 1
0
        // Use this for initialization
        void Start()
        {
            Tree4 tree4Root = new Tree4(new Rect(-50, -50, 100, 100), 0);

            tree4Root.build();
            tree4Root.buildNode8All();

            GameObject go = new GameObject("go0");

            go.transform.position = new Vector3(20f, 0, 13f);
            tree4Root.addGameObject(go);
            go = new GameObject("go1");
            go.transform.position = new Vector3(-20f, 0, 13f);
            tree4Root.addGameObject(go);

            tree4Root.log();

            Tree4 t = tree4Root.findTree4Node(go);

            Debug.LogWarning("find = " + t.rect);

            Tree4 Treebyp = tree4Root.findByPot(new Vector3(0f, 5f, 0f));

            Treebyp.log8();
        }
Exemplo n.º 2
0
 public Tree4 addGameObject(GameObject gameObject)
 {
     if (node0 == null)
     {
         if (!goDic.ContainsKey(gameObject.GetInstanceID()))
         {
             goDic.Add(gameObject.GetInstanceID(), gameObject);
         }
         return(this);
     }
     else
     {
         if (node0.isInRect(gameObject.transform))
         {
             return(node0.addGameObject(gameObject));
         }
         if (node1.isInRect(gameObject.transform))
         {
             return(node1.addGameObject(gameObject));
         }
         if (node2.isInRect(gameObject.transform))
         {
             return(node2.addGameObject(gameObject));
         }
         if (node3.isInRect(gameObject.transform))
         {
             return(node3.addGameObject(gameObject));
         }
     }
     return(null);
 }