Search Unity

Resolved Material Overrides in 2023.1.0b1

Discussion in 'Graphics for ECS' started by Chmyke, Jan 13, 2023.

  1. Chmyke

    Chmyke

    Joined:
    Aug 1, 2012
    Posts:
    34
    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:

    Code (CSharp):
    1. using Unity.Entities;
    2. using Unity.Rendering;
    3. using Unity.Transforms;
    4. using UnityEngine;
    5. using UnityEngine.Rendering;
    6.  
    7. public class Tester : MonoBehaviour
    8. {
    9.     EntityManager entityManager;
    10.  
    11.     public Mesh     mesh;
    12.     public Material material;
    13.  
    14.     RenderMeshDescription renderMeshDescription = new(
    15.         shadowCastingMode: ShadowCastingMode.Off,
    16.         receiveShadows: false);
    17.  
    18.     void Start()
    19.     {
    20.         entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
    21.  
    22.  
    23.         EntityArchetype mainArchetype = entityManager.CreateArchetype(
    24.             typeof(LocalTransform),
    25.             typeof(LocalToWorld),
    26.             typeof(TestoverOverride),
    27.             typeof(RenderMeshArray),
    28.             typeof(RenderBounds));
    29.  
    30.         Entity entityParent = entityManager.CreateEntity(mainArchetype);
    31.  
    32.         RenderMeshUtility.AddComponents(
    33.             entityParent,
    34.             entityManager,
    35.             renderMeshDescription,
    36.             new(new[] { material }, new[] { mesh }),
    37.             MaterialMeshInfo.FromRenderMeshArrayIndices(0, 0));
    38.  
    39.         entityManager.SetComponentData(entityParent, new LocalTransform
    40.         {
    41.             Scale = 1
    42.         });
    43.  
    44.         entityManager.SetComponentData(entityParent, new TestoverOverride
    45.         {
    46.             value = 1,
    47.         });
    48.     }
    49. }
    50.  
    51. [MaterialProperty("Testover")]
    52. public struct TestoverOverride : IComponentData
    53. {
    54.     public float value;
    55. }
    56.  
    57.  
    58. public partial class TestoverSystem : SystemBase
    59. {
    60.     protected override void OnUpdate()
    61.     {
    62.         Entities
    63.             .ForEach((ref TestoverOverride maturityOverride) => { maturityOverride.value = 1000; })
    64.             .ScheduleParallel();
    65.     }
    66. }

    And this my shader.

    Testover.png

    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!
     
  2. Thygrrr

    Thygrrr

    Joined:
    Sep 23, 2013
    Posts:
    700
    I've run into a similar problem updating to 2022.2.2f1 today, instanced properties no longer work on entities (possibly child entities, still debugging).

    It worked in 2022.2.1f1 and before.

    Edit: Confirmed it still works ind 2022.2.1, but not in 2022.2.2
     
    Last edited: Jan 13, 2023
    Chmyke likes this.
  3. Chmyke

    Chmyke

    Joined:
    Aug 1, 2012
    Posts:
    34
    Wonderful! the bug is solved in 2023.1.a25

    Thank you!
     
  4. Chmyke

    Chmyke

    Joined:
    Aug 1, 2012
    Posts:
    34
    Unfortunately, it only worked in the editor, not when the game is build... :(
    (2023.1.0.b1)
     

    Attached Files:

  5. bnmguy

    bnmguy

    Joined:
    Oct 31, 2020
    Posts:
    137
    2023.1.x does not support Entities package yet. Use Entities/DOTS with 2022.2 only for now.
     
    Chmyke likes this.
  6. Chmyke

    Chmyke

    Joined:
    Aug 1, 2012
    Posts:
    34
    Hooray! It's work in editor and build on 2023.1.0b3 :)
     
  7. bnmguy

    bnmguy

    Joined:
    Oct 31, 2020
    Posts:
    137
    Glad to here it!