先定义一个类
using UnityEngine;
namespace DefaultNamespace
{
public class ObjData
{
public string uid;
public GameObject prefab;
public Vector3 pos;
public Vector3 ang;
public ObjData(GameObject prefab, Vector3 pos, Vector3 ang)
{
this.uid = System.Guid.NewGuid().ToString();
this.prefab = prefab;
this.pos = pos;
this.ang = ang;
}
}
}
using UnityEngine;
namespace DefaultNamespace
{
public class Tree
{
public Bounds bound;
private Node root;
public int maxDepth = 6;
public int maxChildCount = 4;
public Tree(Bounds bound)
{
this.bound = bound;
this.root = new Node(bound, 0, this);
}
//插入数据
public void InsertData(ObjData data)
{
root.InsertData(data);
}
public void DrawBound()
{
root.DrawBound();
}
public void TriggerMove(Plane[] planes)
{
root.TriggerMove(planes);
}
}
}
然后进行代码的判断,进行划线
using System.Collections.Generic;
using UnityEngine;
namespace DefaultNamespace
{
public class Node