Comments (5)
True. Atm it's intended, because this code is being generated and we can save a method call. If we start using it in more places, we can extract it to a method.
from entitas.
Yeah, I had to copy it for my own implementation of IComponentCodeGenerator. Not a big deal, but other people might easily miss the pooling part by just calling the component constructor instead. Your decision :)
from entitas.
In general extracting such a method would be nice. Not sure if it makes sense in this case. It's in a generated extension a should not be used from a different generated extension. Offering a generic method componentPool.GetComponent<Position>()
would work but since it's in a generated file I'd rather go for the better performance by writing new PositionComponent()
from entitas.
Hi, a quick follow-up:
Just added entity.CreateComponent() which does all the pooling logic now. It's also used by the code generator now.
e641cf1
public Entity AddPerson(int newAge, string newName) {
var component = CreateComponent<PersonComponent>(ComponentIds.Person);
component.age = newAge;
component.name = newName;
return AddComponent(ComponentIds.Person, component);
}
public Entity ReplacePerson(int newAge, string newName) {
var component = CreateComponent<PersonComponent>(ComponentIds.Person);
component.age = newAge;
component.name = newName;
ReplaceComponent(ComponentIds.Person, component);
return this;
}
from entitas.
Excellent :)
from entitas.
Related Issues (20)
- broken doc link HOT 2
- Wiki closed for editing
- Unity crashes when clicking on a GameObject with Component of Entitas HOT 8
- Remove DesperateDevs dependencies
- [SOLVED] Unity 2022.3.4f1: Exceptions + broken inspector when looking at any entity HOT 16
- Add/Replace/Remove vs Set/Unset HOT 5
- Boolean in setttings for unique components to actually be unique
- A component with multiple contexts +events, only make event listeners for 1 context
- Could not resolve type with token ... expected class System.Threading.CancellationToken HOT 10
- How to generate codes in a project which has several csproj files? HOT 1
- Update on Entitas 2.0-beta and my situation HOT 3
- [1.14.1]code gen twice and compile error HOT 1
- there is a Error, on click Tools/Jenny/Gennerate, how can I do? HOT 4
- _group.GetEntities().AsParallel().ForAll(Execute);这段语句有GC HOT 2
- Is it feasible to use Entitas in the backend? HOT 7
- Entity Behaviour in Unity inspector not visible HOT 2
- Removal of crucial SearchPaths when executing the wiz command
- How to get all group in some context, without reflection。
- GUI Null ref when trying to view entity in inspector HOT 1
- generator issues HOT 1
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 entitas.