Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question [SOLVED] Entity cache can't be cleared

Discussion in 'Entity Component System' started by jennal, Nov 10, 2022.

  1. jennal

    jennal

    Joined:
    Oct 28, 2017
    Posts:
    24
    I keep getting this error

    Code (CSharp):
    1. SerializationException: Failed to deserialize Property=[Value] for Type=[Unity.Collections.FixedString32Bytes]. The default constructed instance does not match the deserialized type. The property needs to be writable, default constructed with the correct type, or ignored by serialization using [DontSerializeAttribute]
    I have only 2 properties with the type of
    FixedString32Bytes
    and the name of
    Value
    . I change the type and name, and the error still there. Even I clear entity cache from perferences, and delete library & obj folders, the error still there.

    How to fully clean cache?
     
  2. jennal

    jennal

    Joined:
    Oct 28, 2017
    Posts:
    24
    I finally know what happened. The
    Value
    is from
    FixedString32Bytes
    and it is a get-only property.

    Code (CSharp):
    1. [Serializable]
    2.     [StructLayout(LayoutKind.Sequential, Size=32)]
    3.     [GenerateTestsForBurstCompatibility]
    4.     public partial struct FixedString32Bytes
    5.         : INativeList<byte>
    6.         , IUTF8Bytes
    7.         , IComparable<String>
    8.         , IEquatable<String>
    9.         , IComparable<FixedString32Bytes>
    10.         , IEquatable<FixedString32Bytes>
    11.         , IComparable<FixedString64Bytes>
    12.         , IEquatable<FixedString64Bytes>
    13.         , IComparable<FixedString128Bytes>
    14.         , IEquatable<FixedString128Bytes>
    15.         , IComparable<FixedString512Bytes>
    16.         , IEquatable<FixedString512Bytes>
    17.         , IComparable<FixedString4096Bytes>
    18.         , IEquatable<FixedString4096Bytes>
    19.     {
    20.         internal const ushort utf8MaxLengthInBytes = 29;
    21.  
    22.         [SerializeField] internal ushort utf8LengthInBytes;
    23.         [SerializeField] internal FixedBytes30 bytes;
    24.  
    25.         /// <summary>
    26.         /// Returns the maximum number of UTF-8 bytes that can be stored in this string.
    27.         /// </summary>
    28.         /// <returns>
    29.         /// The maximum number of UTF-8 bytes that can be stored in this string.
    30.         /// </returns>
    31.         public static int UTF8MaxLengthInBytes => utf8MaxLengthInBytes;
    32.  
    33.         /// <summary>
    34.         /// For internal use only. Use <see cref="ToString"/> instead.
    35.         /// </summary>
    36.         /// <value>For internal use only. Use <see cref="ToString"/> instead.</value>
    37.         [CreateProperty]
    38.         [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
    39.         [ExcludeFromBurstCompatTesting("Returns managed string")]
    40.         public string Value => ToString();
    41.  
    42. ...
    43. }
    So I think this is a bug from
    Unity.Serialization
    .
     
  3. jennal

    jennal

    Joined:
    Oct 28, 2017
    Posts:
    24
  4. jennal

    jennal

    Joined:
    Oct 28, 2017
    Posts:
    24
    I think maybe it is because of nested Fixed structs with structure like this

    Code (CSharp):
    1. public struct A {
    2.     public FixedList4096Bytes<B> List;
    3. }
    4.  
    5. public struct B {
    6.     public int Index;
    7.     public FixedString32Bytes Name;
    8. }
    Now I change
    FixedList4096Bytes<B>
    into
    BlobArray<B>
    , everything works perfectly for now.