|
--3d rt ui 类
|
|
UIRtModelClass = UIRtModelClass or BaseClass(UIPartical)
|
|
UIRtModelClass.using_render_texture_list = {}
|
|
function UIRtModelClass:__init(go,parent, root, model_data)
|
|
self.curr_index = UIRtModelClass.GetRenderTextureIndex()
|
|
self.pos_x = 0
|
|
self.gameObject = go
|
|
self.gameObject.transform.position = Vector3(self.curr_index * 20000,10000, 10000)
|
|
self.model_data = model_data
|
|
self:SetData(parent,root,model_data)
|
|
self:AddEvents()
|
|
end
|
|
|
|
function UIRtModelClass.GetRenderTextureIndex()
|
|
local index = 1
|
|
while (UIRtModelClass.using_render_texture_list[index]) do
|
|
index = index + 1
|
|
end
|
|
UIRtModelClass.using_render_texture_list[index] = true
|
|
return index
|
|
end
|
|
|
|
function UIRtModelClass:__delete()
|
|
UIRtModelClass.using_render_texture_list[self.curr_index] = nil-----------------
|
|
if self.gameObject then
|
|
destroy(self.gameObject, true)
|
|
end
|
|
if self.rt then
|
|
UnityEngine.RenderTexture.ReleaseTemporary(self.rt)
|
|
self.rt = nil
|
|
end
|
|
end
|
|
|
|
function UIRtModelClass:SetData(parent, root, model_data)
|
|
self.camera = self.gameObject.transform:Find("3DUICamera"):GetComponent("Camera")
|
|
self.ui_root = self.gameObject.transform:Find("3DUIRoot").gameObject
|
|
|
|
local root_pos = model_data.root_pos or Vector2(0, 0)
|
|
local root_scale = model_data.root_scale or 1
|
|
local root_rotation = model_data.root_rotation or Vector3(0, 0, 0)
|
|
|
|
if root then
|
|
local root_trans = root.transform
|
|
root:SetActive(true)
|
|
root_trans:SetParent(self.ui_root.transform)
|
|
self:SetRTUILayer(self.ui_root.transform)
|
|
SetLocalScale(root_trans,root_scale, root_scale, root_scale)
|
|
SetAnchoredPosition(root_trans, root_pos.x, root_pos.y)
|
|
root_trans.localRotation = Quaternion.Euler(root_rotation.x, root_rotation.y, root_rotation.z)
|
|
end
|
|
|
|
self.size = self.size or Vector2(600,360)
|
|
if not self.renderSize then
|
|
self.renderSize = self.size
|
|
end
|
|
local temp_x, temp_y = self.size.x, self.size.y
|
|
if not self.rt then
|
|
self.rt = UnityEngine.RenderTexture.GetTemporary(temp_x, temp_y, 24)
|
|
end
|
|
|
|
self.camera.targetTexture = self.rt
|
|
local raw_image = parent:GetComponent("RawImage")
|
|
raw_image.texture = self.rt
|
|
parent.sizeDelta = self.size
|
|
end
|
|
|
|
function UIRtModelClass:AddEvents()
|
|
|
|
end
|