2020.1 Beta 5 & Latest related packages for Hybrid Render V2 - No Entities Showing

2020.1 Beta 5 & Latest related packages for Hybrid Render V2 - No Entities Showing
(I’ve already asked in the DOTS related sub-forum, I thought I’d give it a try in the beta forum next)

I feel this is something simple I’m overlooking?

If I add a sphere with a Convert to Entity component, that will show up in Play Mode. But the following code will no longer (it worked fine in 2019.3 with HR V1) present the Entities I expected at Play Mode time.

Any ideas why not? (I’m using URP)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;
using Unity.Rendering;
using Unity.Jobs;

public class CreateCapsuleSystem : JobComponentSystem
{
    protected override void OnCreate()
    {
        base.OnCreate();

        for (int i = 0; i < 100; i++)
        {

            var instance = EntityManager.CreateEntity(
                ComponentType.ReadOnly<LocalToWorld>(),
                ComponentType.ReadWrite<Translation>(),
                ComponentType.ReadWrite<Rotation>(),
                ComponentType.ReadWrite<NonUniformScale>(),
                ComponentType.ReadOnly<RenderMesh>()
                );


            float3 position = new float3(UnityEngine.Random.Range(-10, 10), 0, UnityEngine.Random.Range(-10, 10));
            float scale = UnityEngine.Random.Range(1, 10);
            EntityManager.SetComponentData(instance,
                new LocalToWorld
                {
                    Value = new float4x4(rotation: quaternion.identity, translation: position)
                });
            EntityManager.SetComponentData(instance, new Translation { Value = position });
            EntityManager.SetComponentData(instance, new Rotation { Value = new quaternion(0, 0, 0, 0) });
            EntityManager.SetComponentData(instance, new NonUniformScale { Value = new float3(scale, scale, scale) });
            var rHolder = Resources.Load<GameObject>("ResourceHolder").GetComponent<ResourceHolder>();

            EntityManager.SetSharedComponentData(instance,
                new RenderMesh
                {
                    mesh = rHolder.theMesh,
                    material = rHolder.theMaterial
                });
        }
    }


    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        return inputDeps;
    }
}

I can’t see your material, but if you’re setting “_MainTex” or otherwise using MainTexture, you may have no texture at all. HDRP shaders at least will often ignore that texture. Run this:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Helpers
{
    public struct ShaderTool
    {
        public static void LogProperties(Material material)
        {
            for(int i = 0; i < material.shader.GetPropertyCount(); i++)
            {
                Debug.Log(i + "..........................................................................................................");
                Debug.Log("Property Name " + i + ": " + material.shader.GetPropertyName(i) + "\n");
                Debug.Log("Property Description " + i + ": " + material.shader.GetPropertyDescription(i) + "\n");
                Debug.Log("Property Type " + i + ": " + material.shader.GetPropertyType(i) + "\n");
                Debug.Log("Property NameID " + i + ": " + material.shader.GetPropertyNameId(i) + "\n");
                if(material.shader.GetPropertyAttributes(i).Length > 0)
                {
                    Debug.Log("Property " + i + " Attributes: \n");
                    for(int j = 0; j < material.shader.GetPropertyAttributes(i).Length; j++)
                    {
                        Debug.Log("     " + i + "." + j + ": " + material.shader.GetPropertyAttributes(i)[j] + "\n");
                    }
                }
            }
        }
    }
}

All your material’s shader properties will be output to the log. In there, you’ll likely find a texture and color property that seems to fit your shader. For example, Unlit shaders may use _UnlitColor and _UnlitColorMap.

This can drive ya nuts, because everything will seem perfect so far as anything written almost anywhere.

1 Like