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

边栏推荐
- Docsify deploy IIS
- The UVM Primer——Chapter2: A Conventional Testbench for the TinyALU
- About the loading of layer web spring layer components, the position of the layer is centered
- Oracle从入门到精通(第4版)
- Linear DP acwing 895 Longest ascending subsequence
- JS10day(api 阶段性完结,正则表达式简介,自定义属性,过滤敏感词案例,注册模块验证案例)
- 软件测试面试题-2022年大厂面试题合集
- Interval DP acwing 282 Stone merging
- Window10 upgrade encountered a big hole error code: 0xc000000e perfect solution
- [opencv learning] [image filtering]
猜你喜欢

Browser node event loop

Apply lnk306gn-tl converter, non isolated power supply

3 A VTT端接 稳压器 NCP51200MNTXG资料

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

js3day(数组操作,js冒泡排序,函数,调试窗口,作用域及作用域链,匿名函数,对象,Math对象)

腾讯三面:进程写文件过程中,进程崩溃了,文件数据会丢吗?

Js10day (API phased completion, regular expression introduction, custom attributes, filtering sensitive word cases, registration module verification cases)

面渣逆袭:MySQL六十六问,两万字+五十图详解!有点六

VIM super practical guide collection of this one is enough

js2day(又是i++和++i,if语句,三元运算符,switch、while语句,for循环语句)
随机推荐
Day4 operator, self increasing, self decreasing, logical operator, bit operation, binary conversion decimal, ternary operator, package mechanism, document comment
Js1day (syntaxe d'entrée / sortie, type de données, conversion de type de données, Var et let différenciés)
Js1day (input / output syntax, data type, data type conversion, VaR and let differences)
软件测试面试题-2022年大厂面试题合集
Heap acwing 839 Simulated reactor
Floyd AcWing 854. Floyd求最短路
Linear DP acwing 896 Longest ascending subsequence II
[opencv learning] [template matching]
国产免费数据仓库ETL调度自动化运维专家—TASKCTL
线性DP AcWing 896. 最长上升子序列 II
哈希表 AcWing 840. 模拟散列表
[opencv learning] [image filtering]
Interview questions for software testing - a collection of interview questions for large factories in 2022
Rust search server, rust quick service finding tutorial
Variable, "+" sign, data type
阿里发布的Redis开发文档,涵盖了所有的redis操作
[opencv learning] [contour detection]
Ntmfs4c05nt1g N-ch 30V 11.9a MOS tube, pdf
What data types does redis have and their application scenarios
The coloring method determines the bipartite graph acwing 860 Chromatic judgement bipartite graph