Wednesday, November 6, 2024
spot_img

unity – Entites are usually not rendering


I caught in the issue that my entites are usually not displaying. I discovered Entities graphic rendering pattern for runtime it completely labored. However when i’m integrating its code, there isn’t any luck. Please inform me what i’m doing unsuitable.

public class EntityRendering : MonoBehaviour
{

    public GameObject prefab; // Reference to the normal prefab
    public Materials entityMaterial; // Materials for use for entities
    public int objectCount = 10000;

    non-public EntityManager entityManager;
    non-public EntityArchetype entityArchetype;

    void Begin()
    {
        entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;

        // Outline the elements that entities could have
        entityArchetype = entityManager.CreateArchetype(
            typeof(RenderMesh),
            typeof(LocalToWorld),
            typeof(ComponentTranslatoin),
            typeof(ComponentRotation),
            typeof(ComponentScale),
            typeof(ComponentMoveSpeed)
        );

        // Create entities
        for (int i = 0; i ().sharedMesh,
                materials = entityMaterial
            });

            // Set preliminary place, rotation, and scale
            entityManager.SetComponentData(entity, new ComponentTranslatoin
            {
                worth = UnityEngine.Random.insideUnitSphere * 10
            });

            entityManager.SetComponentData(entity, new ComponentRotation
            {
                worth = quaternion.id
            });

            entityManager.SetComponentData(entity, new ComponentScale
            {
                worth = new float3(1f, 1f, 1f)
            });

            entityManager.SetComponentData(entity, new ComponentMoveSpeed
            {
                worth = UnityEngine.Random.Vary(1f, 3f)
            });

            var renderMeshArray = new RenderMeshArray(new Materials[] { entityMaterial }, new Mesh[] { prefab.GetComponent().mesh });
            var desc = new RenderMeshDescription(
                shadowCastingMode: ShadowCastingMode.Off,
                receiveShadows: false);
            RenderMeshUtility.AddComponents(entity, entityManager, desc, renderMeshArray, 
                MaterialMeshInfo.FromRenderMeshArrayIndices(0, 0));

        }
    }

I checked that entites are creating in entities/hirachy however not displaying/rendering

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement -spot_img

Latest Articles