Class RenderMeshUtility
Helper class that contains static methods for populating entities so that they are compatible with the Hybrid Renderer.
Namespace: Unity.Rendering
Syntax
public static class RenderMeshUtility
Methods
AddComponents(Entity, EntityCommandBuffer, in RenderMeshDescription)
Set the Hybrid Renderer component values to render the given entity using the given description. Any missing components will be added, which results in structural changes.
Declaration
public static void AddComponents(Entity entity, EntityCommandBuffer ecb, in RenderMeshDescription renderMeshDescription)
Parameters
Type | Name | Description |
---|---|---|
Entity | entity | The entity to set the component values for. |
EntityCommandBuffer | ecb | The EntityCommandBuffer used to set the component values. |
RenderMeshDescription | renderMeshDescription | The description that determines how the entity is to be rendered. |
Examples
void CodeExample()
{
var world = World.DefaultGameObjectInjectionWorld;
var entityManager = world.EntityManager;
var desc = new RenderMeshDescription(
Mesh,
Material);
// RenderMeshUtility can be used to easily create Hybrid Renderer
// compatible entities, but it can only be called from the main thread.
var entity = entityManager.CreateEntity();
RenderMeshUtility.AddComponents(
entity,
entityManager,
desc);
entityManager.AddComponentData(entity, new ExampleComponent());
// If multiple similar entities are to be created, 'entity' can now
// be instantiated using Instantiate(), and its component values changed
// afterwards.
// This can also be done in Burst jobs using EntityCommandBuffer.ParallelWriter.
var secondEntity = entityManager.Instantiate(entity);
entityManager.SetComponentData(secondEntity, new Translation {Value = new float3(1, 2, 3)});
}
AddComponents(Entity, EntityManager, in RenderMeshDescription)
Set the Hybrid Renderer component values to render the given entity using the given description. Any missing components will be added, which results in structural changes.
Declaration
public static void AddComponents(Entity entity, EntityManager entityManager, in RenderMeshDescription renderMeshDescription)
Parameters
Type | Name | Description |
---|---|---|
Entity | entity | The entity to set the component values for. |
EntityManager | entityManager | The EntityManager used to set the component values. |
RenderMeshDescription | renderMeshDescription | The description that determines how the entity is to be rendered. |
Examples
void CodeExample()
{
var world = World.DefaultGameObjectInjectionWorld;
var entityManager = world.EntityManager;
var desc = new RenderMeshDescription(
Mesh,
Material);
// RenderMeshUtility can be used to easily create Hybrid Renderer
// compatible entities, but it can only be called from the main thread.
var entity = entityManager.CreateEntity();
RenderMeshUtility.AddComponents(
entity,
entityManager,
desc);
entityManager.AddComponentData(entity, new ExampleComponent());
// If multiple similar entities are to be created, 'entity' can now
// be instantiated using Instantiate(), and its component values changed
// afterwards.
// This can also be done in Burst jobs using EntityCommandBuffer.ParallelWriter.
var secondEntity = entityManager.Instantiate(entity);
entityManager.SetComponentData(secondEntity, new Translation {Value = new float3(1, 2, 3)});
}