ComponentSystemBase.GetSingleton supposed to support Managed IComponentData???

the title says it all.

The declaration of ComponentSystemBase.GetSingleton is this:

        public T GetSingleton<T>()
            where T : struct, IComponentData
        {
            return CheckedState()->GetSingleton<T>();
        }

But since managed icomponentdata is supposed to make trasition to DOTS more easy it seems to be incorrect.

It probably should allow Managed IComponentData types.

At the bottom of ComponentSystemBase class we have ComponentSystemBaseManagedComponentExtensions which contains this:

        public static T GetSingleton<T>(this ComponentSystemBase sys) where T : class, IComponentData
        {
            var type = ComponentType.ReadOnly<T>();
            var query = sys.GetSingletonEntityQueryInternal(type);
            return query.GetSingleton<T>();
        }

As this has been implemented as an Extension Method, so to access ManagedComponents you need to call this.GetSingleton<T>()

For managed components we get this.HasSingleton<T>() and this.SetSingleton<T>() also. Again, implemented as Extension methods.

1 Like

Also if you don’t want to do anything with ManagedComponents, you can disable that using UNITY_DISABLE_MANAGED_COMPONENTS define in Project settings.