var prefabEntity = new EntityPrefabReference(authoring.Prefab);
EntityPrefabReference : 在 entity 上添加 Prefab 弱引用
RequestEntityPrefabLoaded : 请求 Prefab 加载
PrefabLoadResult : 判断 Prefab 加载完成并实例化
Reference
用 Reference 引用序列化好的, 但是未被加载进内存的 Unity 资产
[Serializable]
public struct References : IComponentData
{
public EntitySceneReference EntitySceneReference;
public EntityPrefabReference EntityPrefabReference;
public WeakObjectSceneReference GameObjectSceneReference;
public WeakObjectReference<GameObject> GameObjectPrefabReference;
}
// A PostLoadCommandBuffer wraps an EntityCommandBuffer that will execute commands
// after the subscene instance is loaded.
var buf = new PostLoadCommandBuffer();
buf.CommandBuffer = new EntityCommandBuffer(Allocator.Persistent, PlaybackPolicy.MultiPlayback);
state.EntityManager.AddComponentData(sceneEntity, buf);