Search Unity

Will blittable struct in a blittable struct make it non-blittable?

Discussion in 'Entity Component System' started by xVergilx, Jan 29, 2019.

  1. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    If both contents are blittable, will it burst if defined like so:
    Code (CSharp):
    1. public struct SomeStruct {
    2.      public AnotherStruct AnotherOne;
    3.      public float2 ....;
    4. }
    5.  
    6. public struct AnotherStruct {
    7.      public float Value;
    8. }
     
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    You can test it yourself

    UnsafeUtility.IsBlittable<SomeStruct>()


    But to answer your question, yes that's fine it'll be blittable.
     
    Joouur and xVergilx like this.
  3. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Cool, thanks!
     
  4. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    No, as long as all members are blittable the resulting struct will also be blittable. This is also true for nested structs
     
    xVergilx likes this.