Unity 中的依赖图解析
有人可以阐明 Unity 如何自动进行依赖图解析吗?我不是在寻找算法的代码,而是在寻找简单的解释,也许还有某种示例或类比。
Can someone shed some light on how Unity automatically does dependency graph resolution? I am not looking for the code of the algorithm, but just a simple explanation, and maybe some sort of example or analogy.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Unity 是一个可扩展库,因此可以自定义和更改它的依赖解析方式。然而,默认的构建计划如下所示:
可以将对象的构建视为多个阶段。此 MSDN 链接很好地总结了各个阶段以及每个阶段默认执行的操作: UnityBuildStage
Unity is an extensible library, so how it does its dependency resolution can be customized and changed. The default build plans however look like the following:
The build up of an object can be thought of in multiple stages. This MSDN link nicely sums up the various stages and what is performed by default at each stage: UnityBuildStage
这只是一个图的遍历问题。它可以是深度优先,也可以是广度优先,或者谁知道还有什么。但事实就是这么简单。
解析
首先解析
X
和Y
。但如果X
是并且Y是
解析
A
和B
和Z
。继续前进,直到到达叶节点。It's just a graph traversal problem. It could be depth-first, or breadth-first or who knows what else. But it's really that simple.
To resolve
First resolve
X
andY
. But ifX
isand Y is
Resolve
A
andB
andZ
too. Keep going till you reach a leaf node.