#This Baker Destroys SubScenes

1 messages · Page 1 of 1 (latest)

sacred siren
#

I get the "EntityHeader could not be loaded" or something error a lot.

Subscene contains 1 Gameobject with nothing on it except this baker; and 5 gameobjects referenced in it. (also breaks with 3)

This is the baker.
Why?

using System;
using Unity.Entities;
using UnityEngine;

namespace Jovian.Authoring
{
    public class ShipRegistryAuthoring : MonoBehaviour
    {
        public GameObject[] ships;
    }

    public class ShipRegistryBaker : Baker<ShipRegistryAuthoring>
    {
        public override void Bake(ShipRegistryAuthoring authoring)
        {
            var self = GetEntity(authoring, TransformUsageFlags.None);
            var buffer = AddBuffer<ShipPrefabRegistryElement>(self);
            
            foreach (var ship in authoring.ships)
            {
                RegisterPrefabForBaking(ship); //breakage happens with or without this, nobody could explain me why this is or isn't needed
                var prefab = GetEntity(ship, TransformUsageFlags.None);
                buffer.Add(new ShipPrefabRegistryElement {prefab = prefab});
            }
        }
    }

    [Serializable]
    public struct ShipPrefabRegistryElement : IBufferElementData
    {
        public Entity prefab;
    }
}

The entities in the gameobject array are fairly simple:

using JetBrains.Annotations;
using Jovian.Components;
using Jovian.ECS.Systems;
using Jovian.Systems;
using Unity.Entities;
using Unity.Mathematics;
using UnityEngine;

namespace Jovian.Authoring
{
    [SelectionBase]
    [DisallowMultipleComponent]
    public class ShipAuthoring : MonoBehaviour
    {
        public float outlineWidth = 1;
        
        public VesselClass vesselClass;

        [Header("Engine Config")]
        public Propulsion propulsion;
    }

    [UsedImplicitly]
    internal class ShipAuthoringBaker : Baker<ShipAuthoring>
    {
        public override void Bake(ShipAuthoring authoring)
        {
            var entity = GetEntity(TransformUsageFlags.Dynamic);

            // Gameplay Logic
            AddComponent(entity, new Vessel {vesselClass = authoring.vesselClass});
            AddComponent(entity, authoring.propulsion);
            AddComponent<ShipControls>(entity);
            AddComponent<PIDControl>(entity);

            // Floating Origin
            AddComponent<Position>(entity);
            AddComponent<Origin>(entity);
            AddComponent<CameraOffset>(entity);
            AddComponent<ScreenPosition>(entity);
            
            // Bootstraps
            AddComponent(entity, new NameBootstrap {name = GetName()});
            AddComponent<TagColliderBootstrap>(entity);
            
            // Shader properties
            AddComponent(entity, new OutlineWidth {value = authoring.outlineWidth});
            AddComponent(entity, new OutlineColor {value = new float4(0, 0, 0, 1)});
            AddComponent(entity, new FactionColor {value = new float4(.5f, .5f, .5f, .1f)});            
        }
    }
}
#

I cleared Library just today, unrelated; if anything, causes more errors.

woven olive
#

no need to use RegisterPRefabForBaking

#

just GetEntity is enough

sacred siren
#

Yeah, I can't find the issue with this either.

#

But this scene breaks the most often.

#

Thank you for taking a look.

#

🙂

quick terrace
#

Yeah looks okay to me.. Registerprefab was used prior to Baking systems i don't this required as Issue said..

#

I had my first header error today in weeks/months but it was after chopping and changing a lot of code around whilst dipping in and out of subscenes.

sacred siren
#

I usually keep them closed. But they get rebaked because I can't (easily) separate this code into assemblies. (I keep adding components, so the components assembly recompiles)

quick terrace
#

There are definitely still some underlying issues with caching code and i'm not sure if it's related to domain reloads or specifically a VS problem ( in my case ) or what, but it pops up occasionally, kindof hard to reproduce

#

The classic fix for the headers error ( prior to it being fixed (faaaaar less common now) ) was clear entities cache ( in Preferences->Entities->Clear Entities Cache ) and/or restart the editor

sacred siren
#

Yeah, that's kind of annoying, and 1 out of 3 times, neither works, then it's delete Library time.

quick terrace
#

Which editor/entities version are you on?

sacred siren
#

2022.3.7f1 with Entities 1.0.14

quick terrace
#

Hmm yeah weird that you're getting it so much.. if it's close to reproducable maybe worth reaching out to the devs