#Anyone knows how to manually initialise

1 messages ยท Page 1 of 1 (latest)

feral orbit
#

Actually wait just reread this message. I dont really see why ConvertToEntitySystem wouldn't work in 0.51. ๐Ÿค”

steel urchin
# feral orbit Actually wait just reread this message. I dont really see why ConvertToEntitySys...

I have a simple world installer in my game project

using Unity.Entities;
using UnityEngine;

public class ECSWorldInstaller : MonoBehaviour
{
    [SerializeField] private string _worldName;
    [SerializeField] private WorldInstallerProcessor[] _processors;

    private World _world;

    public bool TryCreateWorld(string worldName)
    {
        _world = new World(worldName);
        World.DefaultGameObjectInjectionWorld = _world;
        return _world.IsCreated;
    }

    private async void Awake()
    {
        if(!TryCreateWorld(_worldName))
            throw new System.Exception($"World {_worldName} wasn't created");

        //add ConvertToEntitySystem to catch up all converting gameobjects
        DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(_world, typeof(ConvertToEntitySystem));

        foreach (var item in _processors)
            await item.Process(_world);

        //run world
        ScriptBehaviourUpdateOrder.AppendWorldToCurrentPlayerLoop(_world);
    }
    private void OnApplicationQuit()
    {
        _world.Dispose();
    }
}

All it does is just adds ConvertToEntitySystem to world then process world with my custom code (disabled for testing, so nothing happens at this stage) and then add world to player loop. Error happens on 1st update

Console just send me "Value cannot be null" from some convertion code. Looks like some internal data initialized wrong.

feral orbit
#

https://github.com/needle-mirror/com.unity.entities/blob/6129e474c5d51c52548fe7bfa3b13f886ecc7e26/Unity.Entities.Hybrid/ConvertToEntity.cs maybe the gameObjectWorld wasn't properly initialized looking at the ConvertToEntitySystem.

GitHub

[Mirrored from UPM, not affiliated with Unity Technologies.] ๐Ÿ“ฆ The Entities package provides a modern Entity Component System (ECS) implementation with a basic set of systems and components made fo...

#

once you can pinpoint what 'Value' is you could probably find the dependency and see if its possible to init on runtime

steel urchin
#

i've remembered why I don't use ICustomBootstrap. Because it just creates instance of class to use code, so all things should be hardcoded or load settings assets from hardcoded path. So for me manual initialization is better. Though I see really no difference between ICustomBootstrap and from any other code, because in both cases we need to build world from scratch and dev team provide 0 info in docs about how to do it properly today

steel urchin
# feral orbit once you can pinpoint what 'Value' is you could probably find the dependency and...

Value in error is ComponentObject which getting attached during some process in ConvertToEntity.cs

static void InjectOriginalComponents(GameObjectConversionMappingSystem mappingSystem, Transform transform)
        {
            var entity = mappingSystem.GetPrimaryEntity(transform.gameObject);
            foreach (var com in transform.GetComponents<Component>())
            {
                if (com is GameObjectEntity || com is ConvertToEntity || com is StopConvertToEntity)
                    continue;

                mappingSystem.DstEntityManager.AddComponentObject(entity, com);
            }
        }
#

This null component object comes from GameObjectConversionMappingSystem, so yeah maybe game object world isn't initialized well. But what I do wrong? How should I initialize it?

feral orbit
#

I can't remember if you want to do runtime conversion - if that's considered live conversion in 0.51

steel urchin
#

I've figured this out. I have a lot of missing script components on scene gameobjects (in this project I don't use subscenes, so no loud errors) and in 0.17 those gameobjects was perfectly converted, but something changed in 0.51 and somehow missing was converted to null component type, ok ๐Ÿ™‚

feral orbit
#

o

steel urchin