#When creating a Build I got this error cannot convert from 'UnityEngine.GameObject' to 'Unity.Entiti

1 messages · Page 1 of 1 (latest)

tiny frost
#

I don't understand how I get this error, followed the documentationhttps://docs.unity3d.com/Packages/com.unity.entities@1.0/manual/baking-prefabs.html

public struct PrefabReferenceComponent : IComponentData
{
    public EntityPrefabReference prefab;
}

public class HarvesterAuthoring : MonoBehaviour
{
    [Header("Prefab")]
    public GameObject prefab;

    [Header("Infos")]
    public string entityName;
    public Image UIImage;
    public UsableEquipmentType type;
    public float deploymentSpeed;
    public float storageSpeed;

    [Header("Harveser Data")]
    public float timer;
    public float interactDistance;
    public GameObject activeEffectPrefab;

    public class GetPrefabReferenceBaker : Baker<HarvesterAuthoring>
    {
        public override void Bake(HarvesterAuthoring authoring)
        {
            EntityPrefabReference prefabReference = new EntityPrefabReference(authoring.prefab);
            Entity entity = GetEntity(TransformUsageFlags.None);

            if (prefabReference.IsReferenceValid)
            {
                AddComponent(entity, new PrefabReferenceComponent() { prefab = prefabReference });
            }
        }
    }
lilac pulsar
#

Post the full error with the stack trace and point out the line of code it references

balmy harness
#
#if UNITY_EDITOR
        /// <summary>
        /// Construct an EntityPrefabReference from a GameObject.
        /// </summary>
        /// <param name="prefab">The prefab to construct from.</param>
        public EntityPrefabReference(GameObject prefab) : this(
            AssetDatabase.GUIDFromAssetPath(AssetDatabase.GetAssetPath(prefab)))
        {
        }
#endif
#

The constructor is editor only code