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

resource销毁资源,但是资源还在使用的情况下会报错 #187

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

Comments

@fanmingfei
Copy link
Member

原因:
目前渲染和游戏引擎运行时是隔离的,所以resource测无法感知渲染引擎是否使用了资源。
解决方案:
resource侧可以提供引用计数的能力,在插件侧做好使用和销毁的处理。

@fanmingfei fanmingfei added the enhancement New feature or request label Feb 25, 2022
@fanmingfei
Copy link
Member Author

增加 ResourceItem 实例,实例上增加release方法,每次被getResource获取出来一次,ResourceItem上引用计数+1,调用一次release,引用计数-1。在资源 destroy 的时候要判断引用计数。

@terrykingcha
Copy link
Member

如果destroy时发现计数不为0,改如何手动去渲染侧销毁组件?

@fanmingfei
Copy link
Member Author

如果destroy时发现计数不为0,改如何手动去渲染侧销毁组件?

无法销毁。抛出错误提示,当前资源在游戏中还在使用,无法销毁。

@fanmingfei fanmingfei linked a pull request Mar 10, 2022 that will close this issue
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