Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在newGame前addComponent不会生效 #188

Open
fanmingfei opened this issue Feb 25, 2022 · 3 comments
Open

在newGame前addComponent不会生效 #188

fanmingfei opened this issue Feb 25, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@fanmingfei
Copy link
Member

fanmingfei commented Feb 25, 2022

原因:

  • System被添加的以后才会对component的变化进行收集,new Game 以后才会添加System。
  • 另外在设计的时候还要考虑Observer是全局单例的这个问题。

目前a11y解决方案是,加入system的时候,遍历整个gameObjects,找到现有的A11yComponent,添加a11yDom,这种方案问题在于组件要单独去实现。

解决方案:
addSystem的时候去遍历所有Component(new Game的时候另外统一遍历),对添加之前的组件进行一次收集,在下一次update中进行创建。

@terrykingcha
Copy link
Member

这可能是一个设计问题,什么情况必须是先addComponent,再newGame?如果没有这种情况,不允许在newGame前执行addComponent呢?

@fanmingfei
Copy link
Member Author

这可能是一个设计问题,什么情况必须是先addComponent,再newGame?如果没有这种情况,不允许在newGame前执行addComponent呢?

如果是单个Game实例,是可以通过这个方案来解决问题。但是如果是多个实例的话,要判断component归属于哪个Game,需要哪个Game的System去处理。

@fanmingfei fanmingfei linked a pull request Mar 10, 2022 that will close this issue
3 tasks
@fanmingfei
Copy link
Member Author

new Game前 AddComponent 可以在addSystem的时候 遍历内存中所有GameObject来解决。#194

@terrykingcha terrykingcha mentioned this issue Jun 14, 2022
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants