/// <summary>
/// 根据模型的尺寸 取得的模型边缘位置与模型中心的相对位置 (在不适用物理的情况下 模型移动式避免穿模)
/// </summary>
var bounds = GetComponent<MeshRenderer>().bounds;
var size = bounds.max - bounds.min;
_offset = transform.position - bounds.center+ new Vector3(0, bounds.size.y/2,0);
/// <summary>
/// 设置游戏区域 (设置空气墙)
/// </summary>
/// <param name="nothing"></param>
private void onSizeChange(object[] nothing)
{
//存放空气墙的数组
BoxCollider[] Colliders;
//屏幕上四个点
Vector3[] GameArea= new Vector3[] {
camera.WorldToScreenPoint(BorderTop.transform.position),
camera.WorldToScreenPoint(BorderBottom.transform.position),
camera.WorldToScreenPoint(BorderLeft.transform.position),
camera.WorldToScreenPoint(BorderRight.transform.position) };
var camera = GameFrameEntry.GetModule<UIModule>().UICamera;
Vector3[] poses = GameArea;
if (poses == null) return;
var topPos = screenToPlaneProjection((Vector3)poses[0]);
var botPos = screenToPlaneProjection((Vector3)poses[1]);
var leftPos = screenToPlaneProjection((Vector3)poses[2]);
var rightPos = screenToPlaneProjection((Vector3)poses[3]);
Colliders[0].transform.position = topPos;
Colliders[1].transform.position = botPos;
Colliders[2].transform.position = leftPos;
Colliders[3].transform.position = rightPos;
Colliders[4].transform.position = topPos;
}