当前位置:网站首页>Unity SKFramework框架(十九)、POI 兴趣点/信息点
Unity SKFramework框架(十九)、POI 兴趣点/信息点
2022-07-02 09:45:00 【CoderZ1010】
目录
一、简介
POI可以理解为场景中的一些有意义的点,例如车站、商场、医院、监控等等,该功能通常用于数字孪生项目,主要目的是将代表这些点位的二维图标与三维目标位置进行“绑定”,实质内容就是世界坐标转屏幕坐标。如下例所示,我们将一个监控点的图标与模型位置进行绑定:

该工具已经上传至我的框架SKFramework中的开发工具箱,如图所示。


框架已经在Github开源,地址:GitHub - 136512892/SKFramework: Unity SKFramework开发框架

二、使用说明
1.二维与三维的匹配
通过Match函数将POI图标与三维目标进行匹配,其中flag参数表示匹配的标识符,系统会将标识符相同的RectTransform与GameObject进行匹配。
/// <summary>
/// 根据标识符进行匹配
/// </summary>
/// <param name="flag">标识符</param>
/// <param name="rectTransform">RectTransform组件</param>
public void Match(string flag, RectTransform rectTransform);
/// <summary>
/// 根据标识符进行匹配
/// </summary>
/// <param name="flag">标识符</param>
/// <param name="target">三维目标</param>
public void Match(string flag, GameObject target);2.移除
通过Delete函数移除一个POI点,移除后将不再进行世界坐标转屏幕坐标的计算。
/// <summary>
/// 根据标识符移除
/// </summary>
/// <param name="flag">标识符</param>
/// <returns>移除成功返回true 否则返回false</returns>
public bool Delete(string flag);3.UI分辨率
代码中默认认为UI使用的分辨率为1920*1080,需要根据实际进行更改

4.Camera相机
世界坐标与屏幕坐标的转换是通过Camera类中的WorldToScreenPoint函数实现的,因此系统中需要一个Camera主相机,系统初始化时会首先获取场景中Tag标签为MainCamera的相机,如果不存在再通过FindObjectOfType函数查找相机。

三、Example 示例
using UnityEngine;
using SK.Framework;
public class Example : MonoBehaviour
{
[SerializeField] private RectTransform rt;
[SerializeField] private GameObject target;
private void Start()
{
POI.Match("监控1", rt);
POI.Match("监控1", target);
}
}
运行后如图所示:

边栏推荐
- 染色法判定二分图 AcWing 860. 染色法判定二分图
- Execute any method of any class through reflection
- Dijkstra AcWing 850. Dijkstra求最短路 II
- 堆 AcWing 839. 模拟堆
- Ltc3307ahv meets EMI standard, step-down converter qca7005-al33 phy
- Ali was killed by two programming problems at the beginning, pushed inward again, and finally landed (he has taken an electronic offer)
- Linear DP acwing 895 Longest ascending subsequence
- JDBC prevent SQL injection problems and solutions [preparedstatement]
- Win10 system OmniPeek wireless packet capturing network card driver failed to install due to digital signature problem solution
- Rust language document Lite (Part 1) - cargo, output, basic syntax, data type, ownership, structure, enumeration and pattern matching
猜你喜欢

国产免费数据仓库ETL调度自动化运维专家—TASKCTL

js5day(事件监听,函数赋值给变量,回调函数,环境对象this,全选反选案例,tab栏案例)

线性DP AcWing 897. 最长公共子序列

Ali was killed by two programming problems at the beginning, pushed inward again, and finally landed (he has taken an electronic offer)

哈希表 AcWing 840. 模拟散列表

Mobile layout (flow layout)

Fully autonomous and controllable 3D cloud CAD: crowncad's convenient command search can quickly locate the specific location of the required command.

Rust search server, rust quick service finding tutorial

Does C language srand need to reseed? Should srand be placed in the loop? Pseudo random function Rand

bellman-ford AcWing 853. 有边数限制的最短路
随机推荐
ASP. Net MVC default configuration, if any, jumps to the corresponding program in the specified area
堆 AcWing 838. 堆排序
线性DP AcWing 896. 最长上升子序列 II
线性DP AcWing 898. 数字三角形
About the loading of layer web spring layer components, the position of the layer is centered
Hash table acwing 840 Simulated hash table
Should I have a separate interface assembly- Should I have a separate assembly for interfaces?
自主可控三维云CAD:CrownCAD赋能企业创新设计
moon
[opencv learning] [moving object detection]
[200 opencv routines] 100 Adaptive local noise reduction filter
Ali on three sides, it's really difficult to successfully get the offer rated P7
Js10day (API phased completion, regular expression introduction, custom attributes, filtering sensitive word cases, registration module verification cases)
spfa AcWing 851. SPFA finding the shortest path
js 迭代器 生成器 异步代码处理 promise+生成器 -> await/async
区间DP AcWing 282. 石子合并
Mongodb redis differences
Modular commonjs es module
Direct control PTZ PTZ PTZ PTZ camera debugging (c)
JS iterator generator asynchronous code processing promise+ generator - > await/async