Giter Site home page Giter Site logo

Comments (4)

minggo avatar minggo commented on June 22, 2024

ECS 机制下不适合在 Node 里加逻辑去控制。可以通过 Node.getComponentsInChildren() 找到渲染组件,然后去 disable 掉。

from cocos-engine.

kaxifakl avatar kaxifakl commented on June 22, 2024

ECS 机制下不适合在 Node 里加逻辑去控制。可以通过 Node.getComponentsInChildren() 找到渲染组件,然后去 disable 掉。

那能不能把这个标记加在RenderEntity中,Node.getComponentsInChildren()深度遍历的消耗也是很大的

from cocos-engine.

finscn avatar finscn commented on June 22, 2024

ECS 机制下不适合在 Node 里加逻辑去控制。可以通过 Node.getComponentsInChildren() 找到渲染组件,然后去 disable 掉。

那不还是遍历所有子节点 以及会执行 很多的 walk 吗? 性能太低了

from cocos-engine.

finscn avatar finscn commented on June 22, 2024

@minggo 希望正针对这个需求 进一步讨论下.

https://forum.cocos.org/t/topic/158944/ 我在论坛发了个帖子.

renderable 这个名字不好, 可以不用这个名字,但是希望有一个类似的属性.

如果不想增加属性, 希望能提供一个 便于 开发者重写的方式.
现在要在项目里 完全重写 walk 很难 而且walk 过于复杂.

比如

public walk (node: Node, level = 0): void {
    if (!node.activeInHierarchy) {
        return;
    }
    // ....
}

改为

public canWalk(node: Node, level = 0): void {
    return node.activeInHierarchy
}

public walk (node: Node, level = 0): void {
    if (!this.canWalk(node) {
        return;
    }
    // ....
}

这样开发者如果有我这种特殊需求, 可以重写 canWalk.

from cocos-engine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.