Search Unity

Enum in ComponentDataWrapper don't get set on ComponentData

Discussion in 'Entity Component System' started by Ziboo, Mar 21, 2018.

  1. Ziboo

    Ziboo

    Joined:
    Aug 30, 2011
    Posts:
    356
    I tried something like that:
    Code (CSharp):
    1.   public enum FactionType
    2.     {
    3.         Friendly,
    4.         Enemy
    5.     }
    6.  
    7.     [Serializable]
    8.     public struct Faction : IComponentData
    9.     {
    10.         public FactionType Value;
    11.     }
    12.  
    13.     public class FactionComponent : ComponentDataWrapper<Faction>
    14.     {
    15.     }
    But changing the Value on the FactionComponent doesn't change it on the Entity ComponentData.
    I though I was doing something wrong...
    but I checked the "MeshInstanceRendererComponent" which has a ShadowType enum also, and same behaviour...
    You can set the ShadowType to anything at the end it will still be Off
     
  2. Ziboo

    Ziboo

    Joined:
    Aug 30, 2011
    Posts:
    356
    bump
     
  3. DwinTeimlon

    DwinTeimlon

    Joined:
    Feb 25, 2016
    Posts:
    300
    Can show the code where you make the actual assignment? (Remember you are working with structs)
     
  4. Ziboo

    Ziboo

    Joined:
    Aug 30, 2011
    Posts:
    356
    I don't have assignment code. I just have the Component on a GameObject and I set the serialized data.
    You can look at the samples that uses "MeshInstanceRendererComponent".
    When you change the "ShadowType" on this component, the entity will not get the changes.