#How to have a List on a ManagedComponent?

1 messages · Page 1 of 1 (latest)

grave basalt
#

I have a managed component that stores a List (as in System.Collections.Generic) of a scriptable object called UpgradeData. I also need to have an authoring that has a list of this scriptable object, so I can change the available upgrades for a System to choose one between them.

but when I do it, the Unity console logs: ArgumentException: Unknown Type:System.Collections.Generic.List1[UpgradeData]` All ComponentType must be known at compile time. For generic components, each concrete type must be registered with [RegisterGenericComponentType].

I tried using the attribute in various places but nothing works and I'm really confused on how to properly do it.

am I missing something or I just can't have a list in a ManagedComponent?

the code:

using System.Collections.Generic;
using Unity.Entities;
using UnityEngine;

public class PossibleUpgrades : IComponentData {
    public List<UpgradeData> PossibleUpgradesData;
}

public class PossibleUpgradesAuthoring : MonoBehaviour {
    [SerializeField] private List<UpgradeData> possibleUpgrades = new List<UpgradeData>();

    public class Baker : Baker<PossibleUpgradesAuthoring> {
        public override void Bake(PossibleUpgradesAuthoring authoring) {
            var entity = GetEntity(TransformUsageFlags.None);

            AddComponentObject(entity, authoring.possibleUpgrades);
        }
    }
}

quartz glen
#

you are adding list, not your ICD

grave basalt
#

oof

#

sorry, i guess i got lost when using having problems using AddComponent instead of AddComponentObject and looked over this

#

thanks a lot

#

for this and the other post, I'm no longer using the MonoBehaviour for the logic