m_RendererId = ECSGraphicsComponent.Instance.Add(resId, m_RVO.pos, m_RVO.rotation, scale, Unity.Entities.Entity.Null, m_RVO.Id);
//GameObject iconObj = ObjectPoolManager.Instance.GetObjectFromPool(PrefabType.icon,Vector3.zero,Quaternion.identity);
//iconObj.name = iconObj.name+ $"_{this.Id}";
////Icon子物体
//ECSGraphicsComponent.Instance.GenerateEntityFromPrefab(iconObj, new float3(0, 2, 0),Quaternion.identity, 1, m_RendererId);
子物体?
//Unity.Entities.Entity icon = ECSGraphicsComponent.Instance.Add("icon", new float3(0,2,0),Quaternion.identity, 1, m_RendererId);
推荐使用GameObject传统方式显示头像,gameobject位置同步方式见 https://efunstudio.cn/community/gpuanim/文字怎么生成ecs对象;/#post-16
进阶方法有技术难度,不推荐使用。对于非值类型材质参数(可空引用类型),如Texture,DOTS不支持直接修改。可通过创建一张RenderTexture,事先将材质引用这个RenderTexture。新增头像动态合并到RenderTexture中,通过设置shader uv偏移显示不同的头像。shader可参考gpu动画自带帧动画shader做修改GPUFrameAnimLit.shader。通过将头像全部写入一张RenderTexture图集,然后通过帧索引index切换显示哪个头像。
ECS下设置材质值类型参数方法:
值类型参数可参考com.efunstudio.ecsgraphics/Runtime/MaterialProperty下的脚本
1. 将需要设置的材质参数定义为ComponentData, 并通过[MaterialProperty("_PropertyName")]来指定具体关联的shader属性名.
2. 将材质属性ComponentData添加到Entity,通过SetComponentData方法修改属性值