zoukankan      html  css  js  c++  java
  • 项目记录25--unity-tolua框架 View02---BasePanel.lua

    还在,还在。

    。。。

    每天晚上找点时间写点点,多了也不想学到底是什么心理啊。

    写完看电影去。

    今天写两个算超完毕了BaseUI.lua,UIManager.lua(完好中这个)



    local BasePanel = class("BasePanel",require("Base.BaseUI"))


    function BasePanel:ctor(panelName)
    --载入prefab
    local uiTransform = self:_loadPanel(panelName)
    --调用父类
    BasePanel.super.ctor(self,panelName,uiTransform)
    --初始化
    self:_BaseInit()
    --開始默认是隐藏
    self:Hide()
    end


    function BasePanel:_BaseInit(  )
    self:_RegisterComponents()
    self:_Init()
    self:_RegisterEvents()
    end


    --[[
    载入prefab
    ]]
    function BasePanel:_loadPanel(panelName)
    if panelName == nil then
    return
    end
    local path = PREFABS_PATH..panelName
    --安装路径载入prefabe: 区分开发时期和公布时期
    local tempObj = UnityEngine.Resources.Load(path)
    local obj = UnityEngine.Object.Instantiate(tempObj) 
    --设置它父类是UI_ROOT
    obj.transform:SetParent(UIManager:Instance()._uiRoot.transform)
    local rectTransform = obj:GetComponent(typeof(UnityEngine.RectTransform))
    rectTransform.localScale = Vector3.New(1,1,1)
    rectTransform.localPosition = Vector3.New(0,0,0)
    r eturn obj.transform
    end
    --[[


    ]]
    function BasePanel:Show()
    BasePanel.super.Show(self)
    UIManager:Instance():AddPanel(self)
    self._uiTransform:SetAsLastSibling() --设置最前
    end


    --关闭UIPanel 非 Hide
    function BasePanel:Close()
    UIManager:Instance():RemovePanel(self)
    --发出一个关闭的命令
    self:Dispatcher(CLOSE_PANEL_EVENT)
    BasePanel.super.Close(self)
    end


    return BasePanel

  • 相关阅读:
    ASP内置对象
    VBscript脚本语言
    2018校园招聘求职记
    0.3W微功率放大器
    画一画BeagleboneBlack的PCB
    硬件类实习面试经历(已跪)
    2017会是改变人生轨迹的一年
    windows下使用vs code调试简单的C程序
    Beagleboneblack的MLO文件干了些啥
    模仿u-boot的makefile结构
  • 原文地址:https://www.cnblogs.com/lytwajue/p/7358126.html
Copyright © 2011-2022 走看看