当前位置:网站首页>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);
}
}
运行后如图所示:

边栏推荐
- Efficiency comparison between ArrayList and LinkedList
- Ntmfs4c05nt1g N-ch 30V 11.9a MOS tube, pdf
- Rust search server, rust quick service finding tutorial
- Js5day (event monitoring, function assignment to variables, callback function, environment object this, select all, invert selection cases, tab column cases)
- JSON serialization and parsing
- 自主可控三维云CAD:CrownCAD赋能企业创新设计
- JDBC prevent SQL injection problems and solutions [preparedstatement]
- 应用LNK306GN-TL 转换器、非隔离电源
- 一些突然迸发出的程序思想(模块化处理)
- std::vector批量导入快速去重方法
猜你喜欢

完全自主可控三维云CAD:CrownCAD便捷的命令搜索,快速定位所需命令具体位置。

Redis sentinel mechanism and configuration

Dijkstra AcWing 850. Dijkstra finding the shortest circuit II

Five best software architecture patterns that architects must understand

三面阿里,有惊无险成功拿到offer定级P7,只能说是真的难

Js8day (rolling event (scroll family), offset family, client family, carousel map case (to be done))

8 examples of using date commands

Linear DP acwing 902 Shortest editing distance

线性DP AcWing 895. 最长上升子序列

C#运算符
随机推荐
Day4 operator, self increasing, self decreasing, logical operator, bit operation, binary conversion decimal, ternary operator, package mechanism, document comment
[opencv learning] [template matching]
Analog to digital converter (ADC) ade7913ariz is specially designed for three-phase energy metering applications
Package management tools
JDBC 预防sql注入问题与解决方法[PreparedStatement]
Heap acwing 838 Heap sort
js1day(输入输出语法,数据类型,数据类型转换,var和let区别)
Apply lnk306gn-tl converter, non isolated power supply
阿里发布的Redis开发文档,涵盖了所有的redis操作
Jerry's weather code table [chapter]
About the loading of layer web spring layer components, the position of the layer is centered
PXE installation UOS prompt NFS over TCP not available from 10 x.x.x
Direct control PTZ PTZ PTZ PTZ camera debugging (c)
The redis development document released by Alibaba covers all redis operations
Dijkstra AcWing 850. Dijkstra finding the shortest circuit II
bellman-ford AcWing 853. Shortest path with side limit
Interesting interview questions
Redis introduction, scenario and data type
Js4day (DOM start: get DOM element content, modify element style, modify form element attributes, setinterval timer, carousel Map Case)
Typora+docsify quick start