很简单 但又一时想不起来的功能合集
/// <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;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器