少年修仙传客户端代码仓库
client_Hale
2019-04-11 9f89e3be35da42eb9ccb44e6589d62f320aa444c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
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();
        }
    }
 
}