I was having issues with using Shader.PropertyToID in my bursted code, and I couldn't put it in a readonly static int because unity complains if I call it from a static constructor. Instead of just getting it in OnCreate I ended up creating this:
public struct ShaderProperties : IComponentData
{
public int GoalAlpha;
public int WireColor;
}
[WorldSystemFilter(WorldSystemFilterFlags.BakingSystem)]
public partial struct ShaderPropertiesBakingSystem : ISystem
{
public void OnUpdate(ref SystemState state)
{
if (SystemAPI.HasSingleton<ShaderProperties>()) return;
state.EntityManager.CreateSingleton(
new ShaderProperties
{
GoalAlpha = Shader.PropertyToID("_GoalAlpha"),
WireColor = Shader.PropertyToID("_WireColor"),
}
);
}
}
Which worked fine until I made a build. After I made a build none of the systems with a dependency on the component manage to find it for some reason.
If I remove SystemAPI.HasSingleton then unity complains that it can't be created because there already is an entity with that component type.
I feel like I've misunderstood something about how bakers work since this isn't working. I assume I can just make a regular baker that spawns it based on a monobehaviour, it just felt a bit excessive to make an authoring component that'll just be empty.