Hello dear Unity developers,
I can’t get Material Overrides to work in 2023.1.0a is it me or it’s normal?
I’m using Entites 1.0.0-pre.15 and Entites Graphics 1.0.0-pre.15 in a new virgin project.
I use this script to test my material:
using Unity.Entities;
using Unity.Rendering;
using Unity.Transforms;
using UnityEngine;
using UnityEngine.Rendering;
public class Tester : MonoBehaviour
{
EntityManager entityManager;
public Mesh mesh;
public Material material;
RenderMeshDescription renderMeshDescription = new(
shadowCastingMode: ShadowCastingMode.Off,
receiveShadows: false);
void Start()
{
entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
EntityArchetype mainArchetype = entityManager.CreateArchetype(
typeof(LocalTransform),
typeof(LocalToWorld),
typeof(TestoverOverride),
typeof(RenderMeshArray),
typeof(RenderBounds));
Entity entityParent = entityManager.CreateEntity(mainArchetype);
RenderMeshUtility.AddComponents(
entityParent,
entityManager,
renderMeshDescription,
new(new[] { material }, new[] { mesh }),
MaterialMeshInfo.FromRenderMeshArrayIndices(0, 0));
entityManager.SetComponentData(entityParent, new LocalTransform
{
Scale = 1
});
entityManager.SetComponentData(entityParent, new TestoverOverride
{
value = 1,
});
}
}
[MaterialProperty("Testover")]
public struct TestoverOverride : IComponentData
{
public float value;
}
public partial class TestoverSystem : SystemBase
{
protected override void OnUpdate()
{
Entities
.ForEach((ref TestoverOverride maturityOverride) => { maturityOverride.value = 1000; })
.ScheduleParallel();
}
}
And this my shader.
I don’t understand what’s wrong. That’s worked well in Unity 2022 with Entites 1.0.0-pre.12
How can I fix this?
Thank you for your help!