1. 新建一个Prefab,添加图片节点,并设置“关闭时释放资源”
2. 在场景中动态添加这个Prefab
3. 关闭这个Prefab,并调用Laya.Scene.gc()
4. 打印发关,Prefab中的图片资源还在。
log:
open
--------------------------------close-----------------------------------
loader http://localhost:18090/_cache_/9b931ecf-fde9-44dd-acf3-15f8dc807965.ls (2) [5, PrefabImpl]
loader http://localhost:18090/resources/Box.lh (2) [5, PrefabImpl]
loader http://localhost:18090/resources/chest_bg.png (4) [6, Texture, 7, Texture2D]
loader http://localhost:18090/atlas/comp/img_bg.png (4) [6, Texture, 7, Texture2D]
close
--------------------------------gc 6000-----------------------------------
loader http://localhost:18090/resources/chest_bg.png (2) [6, Texture]
loader http://localhost:18090/atlas/comp/img_bg.png (2) [6, Texture]
附件:
LayaTest.zip