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

  • 相关阅读:
    yii2 分页
    yii2 钩子函数
    linux 配置compoer
    Python随心记--迭代器协议和for循环机制
    Python随心记--文件操作处理 open()
    Python随心记--练习
    Python随心记--函数式编程及常用内置函数,及部分实例
    Python随心记--匿名函数
    Python随心记--函数作用域
    Python随心记--局部变量与全局变量
  • 原文地址:https://www.cnblogs.com/lytwajue/p/7358126.html
Copyright © 2011-2022 走看看