UITalkBoard = UITalkBoard or BaseClass(BaseItem)
|
|
function UITalkBoard:__init()
|
|
self.layout_file = "TalkBoard"
|
|
self.base_file = "uiComponent"
|
|
|
|
|
|
self:Load()
|
|
end
|
|
|
|
function UITalkBoard:__delete()
|
|
if self.camera_move_id then
|
|
GlobalEventSystem:UnBind(self.camera_move_id)
|
|
self.camera_move_id = nil
|
|
end
|
|
if self.camera_change_size_id then
|
|
GlobalEventSystem:UnBind(self.camera_change_size_id)
|
|
self.camera_change_size_id = nil
|
|
end
|
|
|
|
if self.delay_timer then
|
|
GlobalTimerQuest:CancelQuest(self.delay_timer)
|
|
self.delay_timer = nil
|
|
end
|
|
end
|
|
|
|
function UITalkBoard:Load_callback()
|
|
self.contentText = self:GetChild("Content"):GetComponent("Text")
|
|
self.bg_image = self:GetChild("Image"):GetComponent("Image")
|
|
|
|
self.bg_con = self:GetChild("Image")
|
|
self.content_con = self:GetChild("Content")
|
|
|
|
self:InitEvent()
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function UITalkBoard:InitEvent()
|
|
|
|
end
|
|
|
|
|
|
|
|
function UITalkBoard:UpdatePos(x,y,z)
|
|
SetLocalPosition(self.transform,x,y,z)
|
|
end
|
|
|
|
function UITalkBoard:SetContent(content,content_width)
|
|
self.gameObject:SetActive(true)
|
|
self.content = content
|
|
|
|
self.contentText.text = content
|
|
self.content_con.sizeDelta = Vector2(content_width,100)
|
|
--20 是 距离上下左右的偏移,另外一个 20 是 下面那个尖尖的高度
|
|
local width = math.min(self.contentText.preferredWidth,content_width)
|
|
local height = self.contentText.preferredHeight
|
|
self.bg_con.sizeDelta = Vector2(width + 20 ,height + 20 + 20)
|
|
self.content_con.localPosition = Vector3(10,height + 20 + 20 - 10,0)
|
|
end
|
|
|
|
function UITalkBoard:StartTimer(time)
|
|
if self.delay_timer == nil then
|
|
local delay_callback = function()
|
|
self:Show(false)
|
|
self.delay_timer = nil
|
|
end
|
|
self.delay_timer = GlobalTimerQuest:AddDelayQuest(delay_callback, time)
|
|
end
|
|
end
|
|
|
|
|
|
function UITalkBoard:Show(bool)
|
|
self.gameObject:SetActive(bool)
|
|
end
|