how about the subscene work with asset bundle. I see the cache data is store in resource folder.
Next step for us is to make the entity cache not be in assets folder but just be a cache like any other asset imports. We will build that on top of addressables. Ultimately we want the entity cache to be creatable by the new asset pipeline in another process with a async non-interrupting workflow.
Letās call whats there right now a āghetto pipelineā, it will get a lot of love in the coming months. It was the simplest way to move it forward step by step unlocking value with a simple solution right now.
Right now all the conversion methods will include Translation and Rotation in the resulting entity prefab. However, one of the advantages of using entity prefabs should be the ability to exclude transform data. Will this be supported in future APIs? Either through new conversion options or the aforementioned ādedicated entity editing toolsā?
How can I have existing monobehaviours or components (eg BoxCollider) on a prefab that I pass into
GameObjectConversionUtility.ConvertGameObjectHierarchy
Iām guessing I should create my own component to represent the BoxCollider and add that to the entity with
IConvertGameObjectToEntity, then use a system to create a gameobject and put a box collider on it then attach it to the entity with EntityManager.AddComponentObject()
I tried using EntityManager.AddComponentObject in IConvertGameObjectToEntity but it didnāt work, Note Iām trying this with a prefab into GameObjectConversionUtility.ConvertGameObjectHierarchy then EntityManager.
Instantiate to make copies of it. Is that the wrong flow?
Hereās an example I just happened to see. You have to implement the Convert method in the IConvertGameObjectToEntity and then looks like you do AddComponentData instead of AddComponentObject.
@Joachim_Ante_1 - adding to @Singtaa 's question, will there be (or is there already a timetable for) something like a ConvertScriptableObjectToEntity pipeline?
Please add abstraction layer for handling asset pipeline, not directly using addressables. Current addressables are lack of many important features like error handling, runtime re-initialization, encryption and so on. I think that making users can use their own asset management system will be more good way.
That really sounds more like feature request for addressables themselves.
Me too, most game project has it own asset management system and it may not suitable for switching to addressable system.
Whatās the end product of this? You want any arbitrary ScriptableObject asset file in Project folder/connected in the scene to become 1 Entity with 1 component object leading to that file?
Yeah also, I donāt think you need a hierarchical conversion tool for ScriptableObjects becauseā¦ they donāt have a hierarchy. =D
But SOās-to-entity workflow is very powerful. And you can already do it today. If you serialize out your CompDatas (via Odin for example), you can create entities from SOās very easily:
using Sirenix.OdinInspector;
using Unity.Entities;
using UnityEngine;
using System.Linq;
using System.Reflection;
[CreateAssetMenu(menuName = "ECS/SOEntityPrefab")]
public class SOEntityPrefab : SerializedScriptableObject {
[SerializeField] IComponentData[] componentDatas;
MethodInfo SetComponentDataMethod = typeof(EntityManager).GetMethod("SetComponentData", BindingFlags.Instance | BindingFlags.Public);
[Button(ButtonSizes.Gigantic)]
void CreateEntity() {
var em = World.Active.GetOrCreateManager<EntityManager>();
var entity = em.CreateEntity(componentDatas.Select(c => new ComponentType(c.GetType())).ToArray());
foreach (var cd in componentDatas) {
var genericMethod = SetComponentDataMethod.MakeGenericMethod(cd.GetType());
genericMethod.Invoke(em, new object[] { entity, cd });
}
}
}
This sample is more for editor/playmode testing. But you can easily create entity prefab for runtime usage as well.
More for the āsingle consistent wayā of an interface + supporting functions, otherwise weāll all wind up hand rolling a solution.
Since there is a way to save a group of entities to an asset (which is what subscenes are using right?) could we build a āscriptable objectā on top of that? Even convert SO->entities asset file->then expose as a singleton.
You can add the StaticEntityOptimization component at the root of a hierarchy to get rid of it. We use that for all buildings in the megacity. Its a super important optimization. It kills off the whole hierarchy at bake time.
You can use GameObjectConversionSystem for this purpose. Check out TransformConversion or
MeshRendererConversion for example code.
the conversion happens at a scene level and you can pull in any data you like. For example you could read the scriptable object data and turn it into ComponentData or DynamicBuffer on an entity.
Next release will also have blob assets which is made for sharable immutable resource data. In that case, you could convert a ScriptableObject into a BlobAsset and then share it from multiple instances in the same scene.
BlobAssets are made for zero cost deserialization for large amounts of data. AnimationClip, CollisionMesh, CurveData is a good example of what we think belongs into a BlobAsset.
This is a really good overview
http://68.183.97.180/gameobject-conversion-ecosystem-code-tour/
Thank @5argon
Itās fine for transform system optimisations, but itās only adds Static component to entity in GameObjectConversionMappingSystem, but for example if we use our GO representation for some thing like - data storage after conversion to entity, which not require TRS, and this components just waste space inside chunk and memory itself (of course itās not so huge, butā¦) I mean idea of just pure data storage entity without any representations itās possible in future for conversion tool?
BTW I found time to test conversion tools and they really cool, I swich all my hardcoded archetypes and own conversion tool for prefabs to built-in conversion tool.
Oohhh that is interesting! I guess this data is blittable or at least usable from jobs? Going to be super handy when passing data to jobs thanks!
Alsoā¦ strings are immutableā¦ soā¦ store strings as blobs?
There is an optimization pipeline and it removes the hierarchy and does a bunch of other data optimization for static entities.