Git Product home page Git Product logo

Comments (5)

wyb10a10 avatar wyb10a10 commented on September 20, 2024 2

这个也安排一下,我会写一个新的示例,把我认为比较合适的解决方案提交。

from cocos_creator_framework.

wulei avatar wulei commented on September 20, 2024

如果A会instantate,说明肯定是有脚本的,必定继承UIView,然后可以在onDestory的时候调用自动释放。

from cocos_creator_framework.

wulei avatar wulei commented on September 20, 2024

还有个建议instantiate的node可以加一个标记
let node = cc.instantiate(prefab) node['__SELF'] = ture
然后在destory的时遍历所有节点有 __SELF 标记的调用一下 node.destory() 否则加载进uiview上的应该内存有问题

不过是我个人见解

from cocos_creator_framework.

Bush16 avatar Bush16 commented on September 20, 2024

from cocos_creator_framework.

wyb10a10 avatar wyb10a10 commented on September 20, 2024

今天花了一天的时间,仔细思考了如何在兼容效率、编写复杂度的情况下实现赋值、Prefab实例化的自动内存管理。具体可以看我新提交的example_res_keeper场景,代码位于ResKeeperExample.ts。

实例化使用ResUtil.instantiate( prefab ),比如实例化了100个对象,会自动在100个对象destroy之后释放资源,如果这个prefab没有被其它地方依赖或者use的话。需要注意的是prefab需要是通过resloader加载的Prefab。

ResKeeper是一个简单的轻量级方案,包括一个spriteframe希望赋值给多个对象,然后自动管理spriteframe的释放,都可以交给ResKeeper组件。

暂时先说这么多吧,最近还有几个资源管理的有用特性需要开发,相信会对大家有所帮助!新年快乐~

from cocos_creator_framework.

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.