docs.unity3d.com
    Show / Hide Table of Contents

    Class RenderMeshUtility

    Helper class that contains static methods for populating entities so that they are compatible with the Hybrid Renderer.

    Inheritance
    Object
    RenderMeshUtility
    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)});
         }
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023