Hi!
I have a small piece of code here which should change the BaseColor:
DynamicBuffer<LinkedEntityGroup> childs = SystemAPI.GetBuffer<LinkedEntityGroup>(_buildingSelectEntity);
foreach(LinkedEntityGroup child in childs){
Entity childEntity = child.Value;
if(SystemAPI.HasComponent<URPMaterialPropertyBaseColor>(childEntity)) {
Debug.Log("Set to green!");
_commandBuffer.SetComponent(childEntity, new URPMaterialPropertyBaseColor {
Value = new float4(0.1f, 0.65f, 0, 1f)
});
}
}
_commandBuffer.Playback(EntityManager);
This component is on the children:
#if URP_10_0_0_OR_NEWER
using Unity.Entities;
using Unity.Mathematics;
namespace Unity.Rendering
{
[MaterialProperty("_BaseColor")]
public struct URPMaterialPropertyBaseColor : IComponentData
{
public float4 Value;
}
[UnityEngine.DisallowMultipleComponent]
public class URPMaterialPropertyBaseColorAuthoring : UnityEngine.MonoBehaviour
{
[Unity.Entities.RegisterBinding(typeof(URPMaterialPropertyBaseColor), nameof(URPMaterialPropertyBaseColor.Value))]
public UnityEngine.Color color;
class URPMaterialPropertyBaseColorBaker : Unity.Entities.Baker<URPMaterialPropertyBaseColorAuthoring>
{
public override void Bake(URPMaterialPropertyBaseColorAuthoring authoring)
{
Unity.Rendering.URPMaterialPropertyBaseColor component = default(Unity.Rendering.URPMaterialPropertyBaseColor);
float4 colorValues;
colorValues.x = authoring.color.linear.r;
colorValues.y = authoring.color.linear.g;
colorValues.z = authoring.color.linear.b;
colorValues.w = authoring.color.linear.a;
component.Value = colorValues;
var entity = GetEntity(TransformUsageFlags.Renderable);
AddComponent(entity, component);
}
}
}
}
#endif
And this is my shader:
The code from me is executed, but the color does not change. According to the script, ‘_BaseColor’ is accessed in the ‘URPMaterialPropertyBaseColor’. This is exactly what I have. However, the color does not change.
Does anyone see where the error is?