当前位置: 首页 > news >正文

Unity DOTS技术(五)Archetype,Chunk,NativeArray

文章目录

  • 一.Chunk和Archetype
      • 什么是Chunk?
      • 什么是ArchType
  • 二.Archetype创建
      • 1.创建实体
      • 2.创建并添加组件
      • 3.批量创建
  • 三.多线程数组NativeArray


本次介绍的内容如下:
在这里插入图片描述

一.Chunk和Archetype

什么是Chunk?

Chunk是一个空间,ECS系统会将相同类型的实体放在Chunk中.当一个Chunk放满后则会创建相同类型的一个Chunk.
当一个Chunk存满了以后会创建新的Chunk进行储存.

什么是ArchType

相同类型的一系列Chunk块称为ArchType

在这里插入图片描述

二.Archetype创建

1.创建实体

当需要创建大量实体的时候,建议使用此方式效率会更高

EntityArchetype tempEntityArchetype = World.DefaultGameObjectInjectionWorld.EntityManager.CreateArchetype();

2.创建并添加组件

并可以在创建时添加实体

EntityArchetype tempEntityArchetype = World.DefaultGameObjectInjectionWorld.EntityManager.CreateArchetype(typeof(PrintComponentData1), typeof(RotationEulerXYZAuthoring3));

3.批量创建

使用For可以实现多个创建

for (int i = 0; i < 200; i++)
{EntityArchetype tempEntityArchetype = World.DefaultGameObjectInjectionWorld.EntityManager.CreateArchetype(typeof(PrintComponentData1), typeof(RotationEulerXYZAuthoring3));
}

三.多线程数组NativeArray

在JobSystem多线程操作中不允许使用普通的List数组,因而我们需要使用NativeArray进行存储操作

EntityArchetype tempEntityArchetype = World.DefaultGameObjectInjectionWorld.EntityManager.CreateArchetype(typeof(PrintComponentData1), typeof(RotationEulerXYZAuthoring3));
// 使用NativeArray创建实体
NativeArray<Entity> tempNativeArray = new NativeArray<Entity>(5, Allocator.Temp);
World.DefaultGameObjectInjectionWorld.EntityManager.CreateEntity(tempEntityArchetype, tempNativeArray);
http://www.lryc.cn/news/363916.html

相关文章:

  • 算法学习笔记(7.1)-贪心算法(分数背包问题)
  • 气膜建筑的施工对周边环境影响大吗?—轻空间
  • 【计算机网络】对应用层HTTP协议的重点知识的总结
  • 30分钟快速入门TCPDump
  • Python | 刷题日记
  • “JS逆向 | Python爬虫 | 动态cookie如何破~”
  • 十.数据链路层——MAC/ARP
  • Linux主机安全可视化运维(免费方案)
  • Vite + Vue 3 前端项目实战
  • python-字符替换
  • 团队项目开发使用git工作流(IDEA)【精细】
  • 爬虫案例实战
  • uniapp uni-popup内容被隐藏问题
  • leetcode155 最小栈
  • 在Ubuntu乌班图上安装Docker
  • 【Redis数据库百万字详解】数据持久化
  • echarts legend. icon的展示
  • PHPstudy情况下上传图片马需要的.htaccess文件
  • 基于最大重叠离散小波变换的PPG信号降噪(MATLAB 2018)
  • Gradio中Button用法及事件监听器click方法使用
  • 【Qt秘籍】[005]-Qt的首次邂逅-创建
  • 亚信安慧AntDB:值得信任的数据产品
  • 超越传统AI 新型多智能体系统MESA,探索效率大幅提升
  • [SWPU 2019]神奇的二维码、buuctf部分web题
  • Python正则表达式匹配中文:深入解析与实战应用
  • 实例Python对比两个word文档并找出不同
  • 2.1 QT随手简记(三)
  • TechM-技术网站
  • SpringBoot: 使用GraalVM编译native应用
  • 9. MySQL事务、字符集