using UnityEngine;
|
using System.Collections;
|
using System.Collections.Generic;
|
using XLua;
|
using System;
|
using System.IO;
|
using Snxxz.UI;
|
|
[LuaCallCSharp]
|
public class LuaWindow : Window
|
{
|
|
public string filePath = "";
|
|
Action luaOnDestroy;
|
|
Action onBindController;
|
Action onAddListeners;
|
Action onPreOpen;
|
Action onAfterOpen;
|
Action onPreClose;
|
Action onAfterClose;
|
Action onActived;
|
Action onLateUpdate;
|
|
private LuaTable table;
|
|
private void Init()
|
{
|
table = LuaUtility.GetNewTable();
|
var meta = LuaUtility.GetNewTable();
|
meta.Set("__index", LuaUtility.Global);
|
table.SetMetaTable(meta);
|
meta.Dispose();
|
|
LuaUtility.Do(filePath, this.gameObject.name, table);
|
|
table.Get("BindController", out onBindController);
|
table.Get("AddListeners", out onAddListeners);
|
table.Get("OnPreOpen", out onPreOpen);
|
table.Get("OnAfterOpen", out onAfterOpen);
|
table.Get("OnPreClose", out onPreClose);
|
table.Get("OnAfterClose", out onAfterClose);
|
table.Get("OnActived", out onActived);
|
table.Get("LateUpdate", out onLateUpdate);
|
|
table.Get("OnDestroy", out luaOnDestroy);
|
}
|
|
void OnDestroy()
|
{
|
if (luaOnDestroy != null)
|
{
|
luaOnDestroy();
|
}
|
|
luaOnDestroy = null;
|
onBindController = null; ;
|
onAddListeners = null; ;
|
onPreOpen = null; ;
|
onAfterOpen = null; ;
|
onPreClose = null;
|
onAfterClose = null; ;
|
onActived = null;
|
onLateUpdate = null;
|
|
if (table != null)
|
{
|
table.Dispose();
|
}
|
}
|
|
protected override void BindController()
|
{
|
Init();
|
|
if (onBindController != null)
|
{
|
onBindController();
|
}
|
}
|
|
protected override void AddListeners()
|
{
|
if (onAddListeners != null)
|
{
|
onAddListeners();
|
}
|
}
|
|
protected override void OnPreOpen()
|
{
|
if (onPreOpen != null)
|
{
|
onPreOpen();
|
}
|
}
|
|
protected override void OnAfterOpen()
|
{
|
if (onAfterOpen != null)
|
{
|
onAfterOpen();
|
}
|
}
|
|
protected override void OnPreClose()
|
{
|
if (onPreClose != null)
|
{
|
onPreClose();
|
}
|
}
|
|
protected override void OnAfterClose()
|
{
|
if (onAfterClose != null)
|
{
|
onAfterClose();
|
}
|
}
|
|
protected override void OnActived()
|
{
|
base.OnActived();
|
|
if (onActived != null)
|
{
|
onActived();
|
}
|
}
|
|
protected override void LateUpdate()
|
{
|
base.LateUpdate();
|
|
if (onLateUpdate != null)
|
{
|
onLateUpdate();
|
}
|
}
|
|
}
|