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

网站首页建设网海南建设银行官方网站

网站首页建设网,海南建设银行官方网站,wordpress 文章归档,辽宁阜新建设学校官方网站SystemBase:支持主线程或多线程执行筛选实体任务。 主要介绍是内部成员:Entities的各种筛选方法,其内部成员还有EntityManager ForEach方法筛选,传递一个有参委托函数进去,参数ref xxx组件类(可填多个&…

SystemBase:支持主线程或多线程执行筛选实体任务。
主要介绍是内部成员:Entities的各种筛选方法,其内部成员还有EntityManager

ForEach方法筛选,传递一个有参委托函数进去,参数ref xxx组件类(可填多个)代表筛选条件。

WithAll:&& 形式筛选组件
WithAny: || 形式筛选组件
WithNone: 筛选出不带某组件的
WithChangeFilter:监听组件数据变化时触发筛选
WithSharedComponentFilter:筛选共享组件(指定特定数据)
WithStoreEntityQueryInField(ref EntityQuery对象):存储筛选结果
WithEntityQueryOptions(EntityQueryOptions):
        EntityQueryOptions.FilterWriteGroup:筛选带[WriteGroup(typeof(xxx))特性的组件
        EntityQueryOptions.IncludeDisabled:具有Disabled(已禁用)组件的实体
        EntityQueryOptions.IncludePrefab:具有Prefab组件的实体
WithoutBurst:不使用Burst编译
WithBurst:使用Burst编译

Run:主线程(单线程执行)
Schedule:多线程并发
ScheduleParallel:多线程并行

using System.Collections;
using System.Collections.Generic;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;
using UnityEngine;
/// <summary>
/// 可操作主线程或多线程; ComponentSystem单线程 JobComponentSystem多线程
/// </summary>
public class MySystemBase : SystemBase
{EntityQuery query;//以下方法从上到下按顺序执行protected override void OnCreate(){Debug.Log("OnCreate");}protected override void OnStartRunning(){Debug.Log("OnStartRunning");}protected override void OnUpdate(){Debug.Log("OnUpdate");//使用内部成员Entities遍历所有实体筛选出Translation组件的实体进行修改Entities.ForEach((ref Translation trans) =>{trans.Value = new Unity.Mathematics.float3(0, 5, 0);}).Run();//使用WithAll增加筛选条件,必须带有PrintTestComponentData组件的//使用Run()代表是主线程执行Entities.ForEach((ref Translation trans) =>{trans.Value = new Unity.Mathematics.float3(0, 5, 0);}).WithAll<PrintTestComponentData>().Run();//WithAny 只要带任意一个即可满足筛选Entities.ForEach((ref Translation trans) =>{trans.Value = new Unity.Mathematics.float3(0, 5, 0);}).WithAny<PrintTestComponentData>().Run();//WithNone 不包含xxx的Entities.ForEach((ref Translation trans) =>{trans.Value = new Unity.Mathematics.float3(0, 5, 0);}).WithNone<PrintTestComponentData>().Run();//WithChangeFilter 监听组件值变化时才触发方法体,参数必须带上ref PrintTestComponentData  否则会报错Entities.ForEach((ref Translation trans, ref PrintTestComponentData data) =>{trans.Value = new Unity.Mathematics.float3(0, 5, 0);}).WithChangeFilter<PrintTestComponentData>().Run();//WithSharedComponentFilter 筛选共享组件 特定值为2的Entities.ForEach((ref Translation trans) =>{trans.Value = new Unity.Mathematics.float3(0, 5, 0);}).WithSharedComponentFilter(new MyShareComponentData() { data = 2 }).Run();//存储筛选结果        Entities.ForEach((ref Translation trans) =>{trans.Value = new Unity.Mathematics.float3(0, 5, 0);}).WithStoreEntityQueryInField(ref query).Run();NativeArray<Entity> array = query.ToEntityArray(Unity.Collections.Allocator.TempJob);foreach (var v in array){//do something}//过滤出带[WriteGroup]特性的组件实体  [WriteGroup(typeof(PrintTestComponentData))] 查询会根据查询中指定的组件的WriteGroupAttribute属性筛选所选实体Entities.ForEach((ref Translation trans) =>{trans.Value = new Unity.Mathematics.float3(0, 5, 0);}).WithEntityQueryOptions(EntityQueryOptions.FilterWriteGroup).Run();//过滤出带[DisableAutoCreation]特性的组件实体  该查询不会隐式的排除具有Disabled(已禁用)组件的实体Entities.ForEach((ref Translation trans) =>{trans.Value = new Unity.Mathematics.float3(0, 5, 0);}).WithEntityQueryOptions(EntityQueryOptions.IncludeDisabled).Run();//过滤出预制体实体  [DisableAutoCreation]  该查询不会隐式的排除具有Prefab组件的实体Entities.ForEach((ref Translation trans) =>{trans.Value = new Unity.Mathematics.float3(0, 5, 0);}).WithEntityQueryOptions(EntityQueryOptions.IncludePrefab).Run();//Schedule 多线程并发执行 ; WithoutBurst 不使用Burst编译Entities.ForEach((ref Translation trans) =>{trans.Value = new Unity.Mathematics.float3(0, 5, 0);}).WithoutBurst().Schedule();//ScheduleParallel 配合Job 多线程并行执行 WithBurst 使用Burst编译Entities.ForEach((ref Translation trans) =>{trans.Value = new Unity.Mathematics.float3(0, 5, 0);}).WithBurst().ScheduleParallel();query.Dispose();array.Dispose();}protected override void OnStopRunning(){Debug.Log("OnStopRunning");}protected override void OnDestroy(){Debug.Log("OnDestroy");}
}

http://www.yayakq.cn/news/605759/

相关文章:

  • 婚纱类网站素材wordpress注册登录修改密码
  • 自己给公司做网站难不难网络建设的网站
  • 简单建优化网站无需技术cpa推广之家
  • 北京网站建设 公司深圳维特网站建设
  • php搭建网站后台网站开发所需资料
  • 做期货的一般看什么网站网站手机模板和pc模板要分开做
  • 做网站公司 上海360建筑网一级消防工程师
  • 什么软件可以发布做网站在哪里学广告设计培训
  • 网站存在的问题及改进措施北京网站设计公司jq成都柚米科技15
  • 做网站 十万数据图表展示网站
  • 网站后台管理系统软件青岛网站建设推广公司
  • 有没有专门做针织衫的网站织梦网站打不开
  • 问答类网站怎么做中国互联网协会副理事长
  • 九一制作网站phpcms双语网站怎么做
  • 徐州建设网站价格天津做网站哪家公司好
  • 南宁自助建站软件做新媒体和网站
  • 网站 设计 案例 简单如何破解网站后台
  • 佛山网站建设公司哪家最好怎么做科技小制作视频网站
  • 东莞保安招聘网网站做优化
  • h5网站网站建设网站前置审批怎么做
  • 什么类型的网站比较容易做wordpress插件地址
  • 南京营销型网站网站开发常遇到的问题有哪些
  • 单纯做seo能否提升网站流量梧州龙圩
  • 移动端网站开发尺寸wordpress 404 调用
  • 西安做网站招聘网页页脚模板
  • 淮南市城乡建设档案馆网站集团网站建设特点 助君
  • 美容公司网站什么做才好酒店如何做网络营销
  • 网站如何301中国互联网百强企业排名
  • 网站制作将栏目分类网站建设家居
  • 南京网站搭建姑苏区网络推广服务