You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
自己多封装几个方法 --- 加载精灵 function ResourcesManager:LoadSprite(path, callback, ...) self:LoadAsync(path, T_Sprite, function(sprite, ...) if not callback then return end callback(not IsNull(sprite) and sprite or nil, ...) end, ...) end
`ResourcesManager():LoadSprite(conf.path, function(sprite)
local unity_uiimage = UIUtil.FindImage(self.Bg)
unity_uiimage.sprite = sprite
有一个动态创建的节点(listItem)已在inspector面板挂有UIImage,脚本里要设置sprite。
我以为这要就可以了
但实际情况,img是UnityEngin.UI.UIImage,并不是UIImage.lua里的那个UIImage。按目前框架一般按如下操作
或许可以再简单些,但是这里的节点是动态创建,传取self:GetComponent的节点路径对view来说不能预先定义
另外,有一个地方可能对于无感知的使用者产生误解。
已在inspector挂了UIImage,为何让使用者在lua里还要AddComponent?是否可以将AddComponent隐藏在框架/接口内部?
The text was updated successfully, but these errors were encountered: