Search Unity

ObjectPropertyBag Error when building

Discussion in 'Entity Component System' started by Roycon, Feb 4, 2020.

  1. Roycon

    Roycon

    Joined:
    Jul 10, 2012
    Posts:
    50
    Hey

    I've been trying to build my project and ran into this error, it happens at build time if IL2CPP or at start on Mono

    IL2CPP error for type 'Unity.Properties.CodeGeneratedPropertyBagRegistry.System_ObjectPropertyBag' in assembly 'C:\Projects\ECS test\Temp\StagingArea\Data\Managed\Assembly-CSharp.dll'
    Additional information: Invalid method 'System.Void Unity.Properties.PropertyBag`1<System.Object>::Accept(TContainer&,TVisitor&,Unity.Properties.ChangeTracker&)' found in vtable for 'Unity.Properties.CodeGeneratedPropertyBagRegistry.System_ObjectPropertyBag'

    I've managed to narrow it down to somewhere in the PropertyBag code generation (what is this for BTW?)
    I made a quick edit to exclude objects from the code gen but I just ran into another issue with List's

    To reproduce, new project with latest entities packages, paste the following code and try to make a IL2CPP build

    Code (CSharp):
    1. public class Test
    2. {
    3.    // public List<object> stringObjectTest;
    4.     public object obj;
    5. }
    6.  
    7. public class TestContainer : IComponentData , IEquatable<TestContainer>
    8. {
    9.     public Test TestClass;
    10.  
    11.     public bool Equals(TestContainer other)
    12.     {
    13.         if (ReferenceEquals(null, other)) return false;
    14.         if (ReferenceEquals(this, other)) return true;
    15.         return Equals(TestClass, other.TestClass);
    16.     }
    17.  
    18.     public override bool Equals(object obj)
    19.     {
    20.         if (ReferenceEquals(null, obj)) return false;
    21.         if (ReferenceEquals(this, obj)) return true;
    22.         if (obj.GetType() != this.GetType()) return false;
    23.         return Equals((TestContainer) obj);
    24.     }
    25.  
    26.     public override int GetHashCode()
    27.     {
    28.         return (TestClass != null ? TestClass.GetHashCode() : 0);
    29.     }
    30. }
    31.  
    (IEquatable was autogenerated via Rider)

    Unfortunately I can't work around this by not have any objects within my ComponentData's as im using class IComponentData's to wrap/interface with 3rd party code and they are using a object field for something

    Also the exception made 0 sense to help narrow this down :)
     
  2. Roycon

    Roycon

    Joined:
    Jul 10, 2012
    Posts:
    50
    Bump

    Can someone from Unity confirm if this is a bug and if I should create a bug report or if this is a intentional error/limitation with a bad error message?
     
  3. silantzis

    silantzis

    Unity Technologies

    Joined:
    Sep 19, 2017
    Posts:
    13
    Hi Roycon,

    This is indeed a bug in the current version.

    Unity.Entities relies on codegen to provide type information for managed components on AOT platforms. In the current version of entities there is minimal support for managed objects with polymorphic types. This is something that is being worked on right now and we are trying to get in for the next release.

    Is this something you need serialized in to a subscene then loaded at runtime? or is this stricly for passing data at runtime?

    For the time being, I would suggest storing these objects in the system itself (e.g. List<object>) and reference them from the IComponentData by index.

    Regarding your question on what it is. Properties is a base package we are developing to describe and visit types/data efficiently. This is the base used for managed object serialization in entities. The PropertyBag object is used to describe a container of data and exposes Properties on it which are consumed by various APIs (serialization, editor UI etc). On AOT platforms we rely on code generation to produce these PropertyBags. The error is a result of this code generation producing invalid code.
     
  4. Roycon

    Roycon

    Joined:
    Jul 10, 2012
    Posts:
    50
    Awesome, thanks for the detailed response

    I'm not using subscenes yet, instead I make heavy use of the IConvertGameObjectToEntity flow and then after the prefab is converted I attach a bunch more Components depending on data I've loaded. One of those components is a wrapper around a asset store package type (Vectrosity) which contains a object field/property somewhere.

    Your suggestion makes sense, I'll replace the IComponentData Vectrosity field with a ID and store them in a list somewhere that my systems can access

    Thanks again for your help
     
  5. linfuqing

    linfuqing

    Joined:
    May 11, 2015
    Posts:
    166
    The bug is not be fixed in Entities 0.7.0-preview.19.Will it be fixed in next version?
     
  6. silantzis

    silantzis

    Unity Technologies

    Joined:
    Sep 19, 2017
    Posts:
    13
    We are aiming to get this in for entities 0.8.0