提交 8a8f0fd0 编写于 作者: L linxinfa

优化LuaPanel的封装

上级 356f9484
......@@ -50,6 +50,7 @@
<Compile Include="Assets\Editor\VersionGUI.cs" />
<Compile Include="Assets\Editor\EditorStyleDef.cs" />
<Compile Include="Assets\Editor\PrefabBinder\PrefabBinderEditor.cs" />
<Compile Include="Assets\Editor\I18NText\I18NTextInspector.cs" />
<Compile Include="Assets\Editor\PrefabBinder\PrefabBinderInspector.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Editor\Extend\ToLua_UnityEngine_GameObject.cs" />
<Compile Include="Assets\Editor\FastOpenTools.cs" />
......@@ -67,7 +68,6 @@
<Compile Include="Assets\LuaFramework\ToLua\Editor\ToLuaExport.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Editor\Extend\ToLua_System_Delegate.cs" />
<Compile Include="Assets\Editor\ResConfigEditor.cs" />
<Compile Include="Assets\Editor\I18NText\I18NTextInspector.cs" />
<Reference Include="UnityEngine">
<HintPath>F:/Unity2019/Editor/2021.1.9f1c1/Editor/Data/Managed/UnityEngine/UnityEngine.dll</HintPath>
</Reference>
......
......@@ -42,8 +42,10 @@
<Compile Include="Assets\LuaFramework\ToLua\Core\LuaDLL.cs" />
<Compile Include="Assets\LuaFramework\Scripts\Network\SocketClient.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_QualitySettingsWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_RectTransformWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_MaterialWrap.cs" />
<Compile Include="Assets\Scripts\Framework\HotUpdate\Downloader.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_UI_InputFieldWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Core\LuaMethodCache.cs" />
<Compile Include="Assets\Scripts\Logic\Test.cs" />
<Compile Include="Assets\Scripts\3rd\LitJson\JsonMockWrapper.cs" />
......@@ -60,16 +62,19 @@
<Compile Include="Assets\Scripts\3rd\LitJson\ParserToken.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\Holoville_HOTween_Plugins_Core_PlugColorWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_CameraClearFlagsWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_UI_GraphicWrap.cs" />
<Compile Include="Assets\Scripts\Framework\Audio\AudioCfg.cs" />
<Compile Include="Assets\LuaFramework\ToLua\BaseType\System_TypeWrap.cs" />
<Compile Include="Assets\LuaFramework\Scripts\ConstDefine\ManagerName.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_SleepTimeoutWrap.cs" />
<Compile Include="Assets\Scripts\Framework\Common\Misc\PrefabBinder.cs" />
<Compile Include="Assets\LuaFramework\Scripts\Network\Protocal.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_UI_SliderWrap.cs" />
<Compile Include="Assets\LuaFramework\Scripts\Framework\AppFacade.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_AudioSourceWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\Holoville_HOTween_Plugins_Core_ABSTweenPluginWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_CustomYieldInstructionWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_UI_SelectableWrap.cs" />
<Compile Include="Assets\Scripts\Framework\Common\Misc\ScreenCapture.cs" />
<Compile Include="Assets\Scripts\Framework\I18N\I18N.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Reflection\LuaProperty.cs" />
......@@ -77,7 +82,9 @@
<Compile Include="Assets\Scripts\Framework\Audio\AudioChannels.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Misc\LuaResLoader.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\PrefabBinderWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_EventSystems_UIBehaviourWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\BaseType\UnityEngine_ParticleSystemWrap.cs" />
<Compile Include="Assets\Scripts\Framework\UGUIExpand\RecyclingScrollView\RecyclingListView.cs" />
<Compile Include="Assets\Scripts\Framework\Event\EventDispatcher.cs" />
<Compile Include="Assets\LuaFramework\ToLua\BaseType\UnityEngine_MeshRendererWrap.cs" />
<Compile Include="Assets\Scripts\Framework\Sprite\SpriteManager.cs" />
......@@ -99,11 +106,13 @@
<Compile Include="Assets\LuaFramework\ToLua\Misc\LuaClient.cs" />
<Compile Include="Assets\Scripts\Framework\Common\Global\GameDef.cs" />
<Compile Include="Assets\LuaFramework\Scripts\Common\CallLuaBehaviour.cs" />
<Compile Include="Assets\Scripts\Framework\Common\Global\Cache.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Core\ToLua.cs" />
<Compile Include="Assets\LuaFramework\ToLua\BaseType\LuaInterface_LuaMethodWrap.cs" />
<Compile Include="Assets\Scripts\View\HotUpdate\HotUpdatePanel.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\LuaFramework_UtilWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_GameObjectWrap.cs" />
<Compile Include="Assets\Scripts\Framework\I18N\LanguageMgr.cs" />
<Compile Include="Assets\Scripts\Framework\Network\RemoteConnection.cs" />
<Compile Include="Assets\Scripts\Framework\Network\NetworkMsgEventRegister.cs" />
<Compile Include="Assets\Scripts\Framework\sproto\src\SpStream.cs" />
......@@ -120,19 +129,25 @@
<Compile Include="Assets\LuaFramework\ToLua\BaseType\LuaInterface_LuaOutWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_KeyCodeWrap.cs" />
<Compile Include="Assets\LuaFramework\Scripts\Utility\WrapCSObj.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_UI_ImageWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\EventDispatcherWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_UI_TextWrap.cs" />
<Compile Include="Assets\Scripts\Framework\Event\EventNameDef.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_MeshColliderWrap.cs" />
<Compile Include="Assets\Scripts\3rd\LitJson\Lexer.cs" />
<Compile Include="Assets\Scripts\Framework\Debug\Logger.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_UI_ButtonWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\BaseType\System_Collections_Generic_Dictionary_ValueCollectionWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\BaseType\UnityEngine_TextureWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_TimeWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\BasePanelWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\CacheWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_ScreenWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_AnimationBlendModeWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_AnimatorWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\GlobalObjsWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_QueueModeWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UGUIToolWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\LuaInterface_DebuggerWrap.cs" />
<Compile Include="Assets\Scripts\Framework\sproto\src\SpTypeManager.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_TransformWrap.cs" />
......@@ -146,6 +161,7 @@
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_RigidbodyWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\BaseType\System_StringWrap.cs" />
<Compile Include="Assets\Scripts\Framework\sproto\src\SpStreamCache.cs" />
<Compile Include="Assets\Scripts\Framework\UGUIExpand\UGUITool.cs" />
<Compile Include="Assets\Scripts\Framework\Common\Misc\DelayCallMgr.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Core\LuaUnityLibs.cs" />
<Compile Include="Assets\Scripts\StartUp.cs" />
......@@ -155,14 +171,17 @@
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_ApplicationWrap.cs" />
<Compile Include="Assets\Scripts\Framework\Resource\ResourceConfigItem.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_RenderSettingsWrap.cs" />
<Compile Include="Assets\Scripts\Framework\I18N\I18NCfgItem.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Core\LuaThread.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Core\ObjectTranslator.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Misc\LuaLooper.cs" />
<Compile Include="Assets\Scripts\Framework\UGUIExpand\RecyclingScrollView\RecyclingListViewItem.cs" />
<Compile Include="Assets\LuaFramework\ToLua\BaseType\UnityEngine_MonoBehaviourWrap.cs" />
<Compile Include="Assets\Scripts\Framework\Common\Misc\WalkCoroutine.cs" />
<Compile Include="Assets\LuaFramework\Scripts\ObjectPool\ObjectPool.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Core\LuaMisc.cs" />
<Compile Include="Assets\LuaFramework\Scripts\ObjectPool\TestObjectClass.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_UI_ToggleWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\BaseType\System_Collections_Generic_ListWrap.cs" />
<Compile Include="Assets\Scripts\Framework\Sprite\SpriteCfgItem.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Core\LuaStatePtr.cs" />
......@@ -176,7 +195,10 @@
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_RenderTextureWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_CapsuleColliderWrap.cs" />
<Compile Include="Assets\Scripts\Framework\Network\RSADERParser.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\AnimationEventTriggerWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_UI_DropdownWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_PlayModeWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_UI_RawImageWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Core\LuaTable.cs" />
<Compile Include="Assets\LuaFramework\ToLua\BaseType\LuaInterface_EventObjectWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_LightTypeWrap.cs" />
......@@ -187,6 +209,7 @@
<Compile Include="Assets\LuaFramework\Scripts\Framework\Core\Controller.cs" />
<Compile Include="Assets\Scripts\Framework\Audio\AudioCfgItem.cs" />
<Compile Include="Assets\LuaFramework\ToLua\BaseType\System_Collections_Generic_KeyValuePairWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\LanguageMgrWrap.cs" />
<Compile Include="Assets\Scripts\Framework\Common\Misc\UnityExtension.cs" />
<Compile Include="Assets\Scripts\Framework\Network\ProtocolProcessor.cs" />
<Compile Include="Assets\Scripts\Framework\Network\NetDataAnalysis.cs" />
......@@ -212,6 +235,7 @@
<Compile Include="Assets\Scripts\3rd\LitJson\Netstandard15Polyfill.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Core\LuaState.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_ShaderWrap.cs" />
<Compile Include="Assets\Scripts\Framework\UGUIExpand\I18NText\I18NText.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_PhysicsWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\Holoville_HOTween_HOTweenWrap.cs" />
<Compile Include="Assets\Scripts\Framework\Common\Misc\ObjectParser.cs" />
......@@ -229,9 +253,11 @@
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\LuaFramework_LuaHelperWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_AudioBehaviourWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_ComponentWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\I18NWrap.cs" />
<Compile Include="Assets\Scripts\Framework\Network\SocketPackageQueue.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Core\TypeChecker.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\DelegateFactory.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_UI_MaskableGraphicWrap.cs" />
<Compile Include="Assets\LuaFramework\Scripts\Utility\Util.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Core\LuaFileUtils.cs" />
<Compile Include="Assets\LuaFramework\ToLua\BaseType\System_ObjectWrap.cs" />
......@@ -267,32 +293,6 @@
<Compile Include="Assets\Scripts\Framework\HotUpdate\HotUpdater.cs" />
<Compile Include="Assets\LuaFramework\ToLua\BaseType\UnityEngine_LightWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Reflection\LuaField.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\I18NWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\AnimationEventTriggerWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_UI_ToggleWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_RectTransformWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_UI_TextWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_UI_SelectableWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_UI_MaskableGraphicWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_UI_ButtonWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_UI_SliderWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_EventSystems_UIBehaviourWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_UI_GraphicWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_UI_RawImageWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_UI_ImageWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_UI_InputFieldWrap.cs" />
<Compile Include="Assets\Scripts\Framework\Common\Global\Cache.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\CacheWrap.cs" />
<Compile Include="Assets\Scripts\Framework\UGUIExpand\UGUITool.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UGUIToolWrap.cs" />
<Compile Include="Assets\Scripts\Framework\UGUIExpand\RecyclingScrollView\RecyclingListView.cs" />
<Compile Include="Assets\Scripts\Framework\UGUIExpand\RecyclingScrollView\RecyclingListViewItem.cs" />
<Compile Include="Assets\Scripts\Framework\UGUIExpand\I18NText\I18NText.cs" />
<Compile Include="Assets\Scripts\Framework\I18N\LanguageMgr.cs" />
<Compile Include="Assets\Scripts\Framework\I18N\I18NCfgItem.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\LanguageMgrWrap.cs" />
<Compile Include="Assets\LuaFramework\ToLua\Source\Generate\UnityEngine_UI_DropdownWrap.cs" />
<Compile Include="Assets\Scripts\Framework\Event\EventNameDef.cs" />
<None Include="Assets\output_log.txt" />
<None Include="Assets\Scripts\代码目录说明.txt" />
<None Include="Assets\LuaFramework\ToLua\readme.txt" />
......
......@@ -12,6 +12,24 @@ function UITool.Instantiate(parent, prefabId)
return obj
end
-- 创建Panel对象
function UITool.CreatePanelObj(instance, base, panelName, panelId, parent)
if nil ~= instance then return instance end
local panel = {
panelName = panelName,
basePanel = nil,
panelObj = nil,
}
setmetatable(panel, base)
panel.basePanel = PanelMgr:ShowPanel(panelId, panel, parent)
return panel
end
-- 关闭Panel
function UITool.HidePanel(instance)
if nil ~= instance and nil ~= instance.basePanel then
instance.basePanel:Hide()
end
end
-- endregion
-- 登录界面
GameHallPanel = GameHallPanel or {}
local this = GameHallPanel
GameHallPanel.__index = GameHallPanel
this.basePanel = nil
this.panelObj = nil
this.accountInput = nil
this.pwdInput = nil
local instance = nil
function GameHallPanel.Show()
this.basePanel = PanelMgr:ShowPanel(PANEL_ID.GAME_HALL_PANEL_ID, "GameHallPanel", GlobalObjs.s_gamePanel)
instance = UITool.CreatePanelObj(instance, GameHallPanel, 'GameHallPanel', PANEL_ID.GAME_HALL_PANEL_ID, GlobalObjs.s_gamePanel)
end
function GameHallPanel.OnShow(parent)
function GameHallPanel.Hide()
UITool.HidePanel(instance)
end
function GameHallPanel:OnShow(parent)
local panelObj = UITool.Instantiate(parent, 10)
this.panelObj = panelObj
self.panelObj = panelObj
local binder = panelObj:GetComponent("PrefabBinder")
this.SetUi(binder)
self:SetUi(binder)
end
-- UI交互
function GameHallPanel.SetUi(binder)
function GameHallPanel:SetUi(binder)
UGUITool.SetButton(binder, "backBtn", function (btn)
this.Hide()
self.Hide()
LoginLogic.DoLogout()
end)
end
function GameHallPanel.Hide()
if nil ~= this.basePanel then
this.basePanel:Hide()
end
end
function GameHallPanel.OnHide()
LuaUtil.SafeDestroyObj(this.panelObj)
function GameHallPanel:OnHide()
LuaUtil.SafeDestroyObj(self.panelObj)
instance = nil
end
\ No newline at end of file
-- 登录界面
LoginPanel = LoginPanel or {}
local this = LoginPanel
this.basePanel = nil
this.panelObj = nil
LoginPanel.__index = LoginPanel
local instance = nil
function LoginPanel.Show()
this.basePanel = PanelMgr:ShowPanel(PANEL_ID.LOGIN_PANEL_ID, "LoginPanel", GlobalObjs.s_gamePanel)
instance = UITool.CreatePanelObj(instance, LoginPanel, 'LoginPanel', PANEL_ID.LOGIN_PANEL_ID, GlobalObjs.s_gamePanel)
end
function LoginPanel.Hide()
UITool.HidePanel(instance)
end
function LoginPanel.OnShow(parent)
function LoginPanel:OnShow(parent)
local panelObj = UITool.Instantiate(parent, 3)
this.panelObj = panelObj
self.panelObj = panelObj
local binder = panelObj:GetComponent("PrefabBinder")
this.SetUi(binder)
self:SetUi(binder)
end
-- UI交互
function LoginPanel.SetUi(binder)
function LoginPanel:SetUi(binder)
-- 账号输入框
local accountInput = binder:GetObj("accountInput")
accountInput.text = Cache.Get("ACCOUNT", "")
......@@ -46,7 +48,7 @@ function LoginPanel.SetUi(binder)
LoginLogic.DoLogin(account, pwdMd5, function (ok)
if not ok then return end
-- 登录成功,关闭登录界面
this.Hide()
self.Hide()
-- 进入大厅界面
GameHallPanel.Show()
end)
......@@ -59,12 +61,7 @@ function LoginPanel.SetUi(binder)
language.value = LanguageMgr.languageIndex
end
function LoginPanel.Hide()
if nil ~= this.basePanel then
this.basePanel:Hide()
end
end
function LoginPanel.OnHide()
LuaUtil.SafeDestroyObj(this.panelObj)
function LoginPanel:OnHide()
LuaUtil.SafeDestroyObj(self.panelObj)
instance = nil
end
\ No newline at end of file
......@@ -7,7 +7,7 @@ public class BasePanelWrap
public static void Register(LuaState L)
{
L.BeginClass(typeof(BasePanel), typeof(UnityEngine.MonoBehaviour));
L.RegFunction("Init", Init);
L.RegFunction("LuaBind", LuaBind);
L.RegFunction("Show", Show);
L.RegFunction("Hide", Hide);
L.RegFunction("__eq", op_Equality);
......@@ -16,14 +16,14 @@ public class BasePanelWrap
}
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
static int Init(IntPtr L)
static int LuaBind(IntPtr L)
{
try
{
ToLua.CheckArgsCount(L, 2);
BasePanel obj = (BasePanel)ToLua.CheckObject(L, 1, typeof(BasePanel));
string arg0 = ToLua.CheckString(L, 2);
obj.Init(arg0);
LuaTable arg0 = ToLua.CheckLuaTable(L, 2);
obj.LuaBind(arg0);
return 0;
}
catch(Exception e)
......
......@@ -84,7 +84,7 @@ public class PanelMgrWrap
ToLua.CheckArgsCount(L, 4);
PanelMgr obj = (PanelMgr)ToLua.CheckObject(L, 1, typeof(PanelMgr));
int arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
string arg1 = ToLua.CheckString(L, 3);
LuaTable arg1 = ToLua.CheckLuaTable(L, 3);
UnityEngine.Transform arg2 = (UnityEngine.Transform)ToLua.CheckUnityObject(L, 4, typeof(UnityEngine.Transform));
BasePanel o = obj.ShowPanel(arg0, arg1, arg2);
ToLua.Push(L, o);
......
using System.Net.Security;
using UnityEngine;
using LuaInterface;
public class BasePanel : MonoBehaviour
{
public void Init(string moduleName)
public void LuaBind(LuaInterface.LuaTable luaObj)
{
var lua = LuaFramework.LuaManager.instance;
luaFuncOnShow = lua.GetFunction(moduleName + ".OnShow", false);
luaFuncOnHide = lua.GetFunction(moduleName + ".OnHide", false);
luaFuncUpdate = lua.GetFunction(moduleName + ".Update", false);
luaFuncRegistEvent = lua.GetFunction(moduleName + ".RegistEvent", false);
luaFuncUnRegistEvent = lua.GetFunction(moduleName + ".UnRegistEvent", false);
m_luaObj = luaObj;
luaFuncOnShow = luaObj.GetLuaFunction("OnShow");
luaFuncOnHide = luaObj.GetLuaFunction("OnHide");
luaFuncUpdate = luaObj.GetLuaFunction("Update");
luaFuncRegistEvent = luaObj.GetLuaFunction("RegistEvent");
luaFuncUnRegistEvent = luaObj.GetLuaFunction("UnRegistEvent");
}
protected virtual void Awake()
......@@ -28,7 +27,7 @@ public class BasePanel : MonoBehaviour
protected virtual void Update()
{
if (null != luaFuncUpdate)
luaFuncUpdate.Call();
luaFuncUpdate.Call(m_luaObj);
}
public virtual void Show()
......@@ -47,14 +46,14 @@ public class BasePanel : MonoBehaviour
protected virtual void RegistEvent()
{
if (null != luaFuncRegistEvent)
luaFuncRegistEvent.Call();
luaFuncRegistEvent.Call(m_luaObj);
}
protected virtual void OnShow(Transform parent)
{
if (null != luaFuncOnShow)
luaFuncOnShow.Call(parent);
luaFuncOnShow.Call(m_luaObj, parent);
}
public virtual void Hide()
......@@ -72,13 +71,13 @@ public class BasePanel : MonoBehaviour
protected virtual void OnHide()
{
if (null != luaFuncOnHide)
luaFuncOnHide.Call();
luaFuncOnHide.Call(m_luaObj);
}
protected virtual void UnRegistEvent()
{
if (null != luaFuncUnRegistEvent)
luaFuncUnRegistEvent.Call();
luaFuncUnRegistEvent.Call(m_luaObj);
}
/// <summary>
......@@ -86,6 +85,7 @@ public class BasePanel : MonoBehaviour
/// </summary>
private int m_state = 0;
private LuaInterface.LuaTable m_luaObj;
private GameObject m_selfObj;
private Transform m_selfTransform;
private LuaFunction luaFuncOnShow;
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class PanelMgr
{
......@@ -20,12 +18,12 @@ public class PanelMgr
return panel;
}
public BasePanel ShowPanel(int panelId, string moduleName, Transform parent)
public BasePanel ShowPanel(int panelId, LuaInterface.LuaTable luaObj, Transform parent)
{
var panel = GetPanelById(panelId);
if (null == panel)
{
var go = new GameObject(moduleName);
var go = new GameObject(luaObj.GetStringField("panelName"));
go.transform.SetParent(parent, false);
var rectTrans = go.AddComponent<RectTransform>();
rectTrans.anchorMin = Vector2.zero;
......@@ -33,13 +31,14 @@ public class PanelMgr
rectTrans.offsetMin = Vector2.zero;
rectTrans.offsetMax = Vector2.zero;
panel = go.AddComponent<BasePanel>();
panel.Init(moduleName);
panel.LuaBind(luaObj);
m_panelMap.Add(panelId, panel);
}
panel.Show();
return panel;
}
public T ShowPanel<T>(int panelId, Transform parent) where T : BasePanel
{
var panel = GetPanelById(panelId);
......@@ -53,7 +52,6 @@ public class PanelMgr
rectTrans.offsetMin = Vector2.zero;
rectTrans.offsetMax = Vector2.zero;
panel = go.AddComponent<T>();
panel.Init(typeof(T).ToString());
m_panelMap.Add(panelId, panel);
}
panel.Show();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册