layabox / LayaAir

LayaAir is a fully platform rendering engine with rich 2D/3D rendering capabilities and a mature integrated development platform

Home Page:https://www.layaair.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Scene.load(url, complete, progress) 能不能把内嵌其他ui资源也一起加载了

zsytssk opened this issue · comments

比方说一个场景A中使用了ui B,B下面有节点C;
现在在A load之后,B并没有加载;
如果在A的onEnable中使用B.C 就会报错;
现在我只能将B变成内嵌资源,没发现其他好的方式。。。

@chenshch

我觉得你应该换个思路,这种逻辑应该放在C里处理,而不是B。B只负责通知C处理,不用B.C

------------------ 原始邮件 ------------------ 发件人: "张世阳"<notifications@github.com>; 发送时间: 2020年9月2日(星期三) 下午4:17 收件人: "layabox/LayaAir"<LayaAir@noreply.github.com>; 抄送: "Subscribed"<subscribed@noreply.github.com>; 主题: [layabox/LayaAir] Scene.load(url, complete, progress) 能不能把内嵌其他ui资源也一起加载了 (#371) 比方说一个场景A中使用了ui B,B下面有节点C; 现在在A load之后,B并没有加载; 如果在A的onEnable中使用B.C 就会报错; 现在我只能将B变成内嵌资源,没发现其他好的方式。。。 — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

实际上我只有A绑定一个脚本 B C 都没有, 在很多时候都是这样的(如果你用laya做过游戏就会明白);
即使你说的那种方式 也是不行的, 比方说 A和B都都绑定一个脚本;
A中调用A.B只能是在A.onEnabled之后才可以, 调用B.C只能在B.onEabled之后才行, 我在A中不能知道B什么时候onEabled
如果我在A.onEnabled马上调用B中引用C的方法就会出错...(这你应该没有疑问吧);


这个问题的关键是父UI并不能不能知道子UI什么加载完成, 引擎没有提供相应的api(也许有我不知道,如果有希望你能说下), 而这我觉得是一个基础的功能, 引擎应该提供的...