Comments (6)
There are currently plans to integrate with the conversion systems and provide this API, however it is currently not possible due to the required functionality being internal to the entities packages.
Due to the nature of SpatialOS networking there is no guarantee that we already have access to the Metadata component at the time we create the ECS entity.
If we want to "create" the entity once the Metadata
has been checked out, we'd be too late as we now already have an ECS entity that is linked to the SpatialOS entity.
The solution is to spawn an entity with GameObjectConversionUtility.ConvertGameObjectHierarchy()
, and somehow merge the new root entity with our already existing entity.
Sadly the functionality to copy all components from 1 entity to another, and remap any entity id's, is internal to the entities packages and cannot be accessed by us even through use of reflection.
We're looking for methods around this, but until then we won't have proper support for the conversion workflow.
from gdk-for-unity.
Are you talking about GameObject -> Entity conversion?
Unity already provide enough tools to convert GameObject to Entities, I see no benefits for you to reinvneting the wheel, cloning entities sounds more sensible for me, as it support games go for pure ECS .
I'm sorry for the issue being unclear, but I was talking about letting users directly provide their entity (ECS) to act as SpatialOS managed entity (ECS) prefab, so once Spatial start syncing a world entity (Spatial -sync-> ECS), it clones the provided entity (ECS) instead of create a empty entity (ECS).
I understand you have your design concerns, just out of curiosity, if you don't mind 😉 I'd like to know what makes it impossible to
- use
EntityManager.Instantiate()
to clone an entity with desired ECS data - SpatialOS add all required components
- (Nothing more to do, all components ready for systems to query)
instead of
EntityManager.CreateEntity()
to create a empty entity- SpatialOS add all required components
- Users query for new entities and add desired components then set components data.
from gdk-for-unity.
The issue is that, at the time of entity creation, you will have no information about what kind of entity it is. For example, you won't have the Metadata
component. So how would you pick the prefab to convert into your new entity to add the Spatial OS components too?
from gdk-for-unity.
I agree with you what prefab to use would be the problem, I was aware of this when raising this issue.
Proposal
...
- As current EcsViewSystem.AddEntity(EntityId) takes an EntityId, allowing users to register a (EntityId, Entity) to a dictionary in the EcsViewSystem maybe the most compatible way. Users would have to do this before they send the CreateEntity world commands.
...
Metadata
is the natural choice for this case, I totally agree with that, at the same time I also feels your current design is pretty nice. That's why I mentioned the first idea: Since you are already offering ID reservations tools, It seems acceptable (just my opinion of course😁) to decide which Entity (ECS) to use in EcsViewSystem.AddEntity()
by EntityId
.
Changing existing signatures is not needed, and the flow looks okay:
-> Reserving a EntityId
-> (Optional) Set (EntityID, Entity) to EcsViewSystem
-> WorldCommands.CreateEntity
at the time of entity creation, you will have no information about what kind of entity it is
In this case, it would be the user'd already know all components (prefab's + spatial's) the entity would have at the time of sending the creation command.
Even we eventually can use Metadata
, this EntityId
approach can still used to override for individual entity. (What if a devloper does not want to tie prefab to Metatdata
?)
What do you think? What cons do you see in the idea? Not saying that you should accept it, it's just me like to discuss with and learn from people working on big systems.
from gdk-for-unity.
In your example, only the worker that requests the entity spawn will know what prefab entity to use.
How do you propose other workers, such as clients, will create the ecs entity once they check out the newly created SpatialOS entity?
from gdk-for-unity.
Solid point, I totally missed that! Not I see what you meant there's no way to achieve this (with current systems). Thanks! 😃
from gdk-for-unity.
Related Issues (20)
- MonoBehaviours with a WorkerType annotation, but no requirables, do not get enabled HOT 1
- Local launch errors on MacOS when project path contains spaces HOT 1
- Logfile location for parsing port incorrect on MacOS HOT 14
- Builds which aren't required and the user does not have build support for are not skipped HOT 2
- Schema compiler errors are swallowed by the code generator HOT 2
- The Mobile Launcher window doesn't find Android devices with hyphens in their name HOT 2
- Windows Unable to use Local Launch HOT 4
- 'NetworkConnectionType' does not contain a definition for 'ModularKcp' HOT 3
- ECS Workflow usage HOT 7
- Batch EntityID reservation HOT 2
- StackOverFlowException on sending CreateEntity HOT 7
- Feature Request: Support ISharedComponentData generation HOT 4
- Feature Request: Toggling managed worker in local launch HOT 4
- Local runtime (Java) memory leak with Inspector opened HOT 7
- "Map Builder" function is undocumented. HOT 1
- SpatialOS Launcher only accept client workers named with UnityClient/UnrealClient/LauncherClient HOT 5
- Build target marked as build, but not required will fail builds if the build support is not installed HOT 1
- Deployment launcher no perms
- InvalidCastException with Coordinates field in User Defined Type
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gdk-for-unity.