Skip to content

Commit debd78e

Browse files
committed
ILRuntime模块代码整理。
1 parent 2501b36 commit debd78e

19 files changed

+95
-59
lines changed

Assets/Scene/King.unity

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ GameObject:
127127
- component: {fileID: 1514884857}
128128
- component: {fileID: 1514884854}
129129
- component: {fileID: 1514884855}
130-
- component: {fileID: 1514884856}
131130
m_Layer: 0
132131
m_Name: Main Object
133132
m_TagString: Untagged
@@ -209,18 +208,6 @@ MonoBehaviour:
209208
m_Script: {fileID: 11500000, guid: 3e96d3d6f1474d34398e00281e7089f1, type: 3}
210209
m_Name:
211210
m_EditorClassIdentifier:
212-
--- !u!114 &1514884856
213-
MonoBehaviour:
214-
m_ObjectHideFlags: 0
215-
m_CorrespondingSourceObject: {fileID: 0}
216-
m_PrefabInstance: {fileID: 0}
217-
m_PrefabAsset: {fileID: 0}
218-
m_GameObject: {fileID: 1514884849}
219-
m_Enabled: 1
220-
m_EditorHideFlags: 0
221-
m_Script: {fileID: 11500000, guid: 870553841b8035a409c07e21850052fd, type: 3}
222-
m_Name:
223-
m_EditorClassIdentifier:
224211
--- !u!114 &1514884857
225212
MonoBehaviour:
226213
m_ObjectHideFlags: 0

Assets/Script/Main/CasinosContext.cs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
namespace Casinos
44
{
5-
using System;
5+
//using System;
66
using System.Collections.Generic;
77
using System.IO;
88
using System.Text;
99
using UnityEngine;
1010
using XLua;
1111
using FairyGUI;
12+
using ILRuntime.Runtime.Enviorment;
13+
using ILRuntime.Runtime.Generated;
1214

1315
public enum _eProjectItemDisplayNameKey
1416
{
@@ -55,6 +57,7 @@ public class CasinosContext
5557
FTMgr FTMgr { get; set; }
5658
HeadIconMgr HeadIconMgr { get; set; }
5759
SoundMgr SoundMgr { get; set; }
60+
CasinosILRuntime CsRuntime { get; set; }
5861

5962
//---------------------------------------------------------------------
6063
public CasinosContext(bool is_editor_debug)
@@ -179,6 +182,11 @@ public void Update(float elapsed_tm)
179182
LuaMgr.Update(elapsed_tm);
180183
}
181184

185+
if (CsRuntime != null)
186+
{
187+
CsRuntime.Update();
188+
}
189+
182190
if (TimerShaft != null)
183191
{
184192
TimerShaft.ProcessTimer((ulong)Stopwatch.ElapsedMilliseconds);
@@ -229,6 +237,12 @@ public void Close()
229237
NativeAPIMsgReceiverListner = null;
230238
}
231239

240+
if (CsRuntime != null)
241+
{
242+
CsRuntime.Destroy();
243+
CsRuntime = null;
244+
}
245+
232246
if (LuaMgr != null)
233247
{
234248
LuaMgr.Release();
@@ -272,11 +286,11 @@ public void Launch()
272286

273287
if (IsEditorDebug)
274288
{
275-
string p = Path.Combine(Environment.CurrentDirectory, "./DataOss/");
289+
string p = Path.Combine(System.Environment.CurrentDirectory, "./DataOss/");
276290
var di = new DirectoryInfo(p);
277291
string p1 = di.FullName.Replace('\\', '/');
278292

279-
string lua_root = Environment.CurrentDirectory + "/Assets/Script.Lua/";
293+
string lua_root = System.Environment.CurrentDirectory + "/Assets/Script.Lua/";
280294
PathMgr.DirLuaRoot = lua_root.Replace('\\', '/');
281295
PathMgr.DirRawRoot = p1 + "Common/Raw/";
282296
PathMgr.DirAbRoot = p1 + Config.Platform + "/Resources.KingTexas/";
@@ -288,13 +302,18 @@ public void Launch()
288302
PathMgr.DirAbRoot = PathMgr.CombinePersistentDataPath("Resources.KingTexas/");
289303
}
290304

305+
PathMgr.DirCsRoot = PathMgr.CombinePersistentDataPath("Cs/");
306+
291307
PathMgr.DirAbUi = PathMgr.DirAbRoot + "Ui/";// "Resources.KingTexas/Ui/",需动态计算
292308
PathMgr.DirAbCard = PathMgr.DirAbRoot + "Cards/";// "Resources.KingTexas/Cards/",需动态计算
293309
PathMgr.DirAbAudio = PathMgr.DirAbRoot + "Audio/";// "Resources.KingTexas/Audio/",需动态计算
294310
PathMgr.DirAbItem = PathMgr.DirAbRoot + "Item/";// "Resources.KingTexas/Item/",需动态计算
295311
PathMgr.DirAbParticle = PathMgr.DirAbRoot + "Particle/";// "Resources.KingTexas/Particle/",需动态计算
296312

297313
LuaMgr.Launch(!version_persistent);
314+
315+
CsRuntime = new CasinosILRuntime();
316+
CsRuntime.Create();
298317
}
299318

300319
//-------------------------------------------------------------------------

Assets/Script/Main/MbILRuntime.cs renamed to Assets/Script/Main/CasinosILRuntime.cs

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,26 @@
33
using System.IO;
44
using ILRuntime.Runtime.Enviorment;
55
using ILRuntime.Runtime.Generated;
6-
using UnityEngine;
76

8-
public class MbILRuntime : MonoBehaviour
7+
public class CasinosILRuntime
98
{
109
//-------------------------------------------------------------------------
1110
// AppDomain是ILRuntime的入口,最好是在一个单例类中保存,整个游戏全局就一个,这里为了示例方便,每个例子里面都单独做了一个
12-
// 大家在正式项目中请全局只创建一个AppDomain
11+
// 全局只创建一个AppDomain
1312
// 首先实例化ILRuntime的AppDomain,AppDomain是一个应用程序域,每个AppDomain都是一个独立的沙盒
1413
AppDomain AppDomain { get; set; } = new ILRuntime.Runtime.Enviorment.AppDomain();
1514

1615
//-------------------------------------------------------------------------
17-
void Start()
16+
public void Create()
1817
{
19-
//StartCoroutine(LoadHotFixAssembly());
20-
LoadHotFixAssembly();
21-
}
18+
return;
2219

23-
//-------------------------------------------------------------------------
24-
void LoadHotFixAssembly()
25-
{
26-
string s = Application.streamingAssetsPath;
27-
s = s.Replace('\\', '/');
28-
s = s.Replace("Assets/StreamingAssets", "");
29-
s += "Script.CSharp/bin/Release/";
20+
//string s = Application.streamingAssetsPath;
21+
//s = s.Replace('\\', '/');
22+
//s = s.Replace("Assets/StreamingAssets", "");
23+
//s += "Script.CSharp/bin/Release/";
24+
25+
string s = Casinos.CasinosContext.Instance.PathMgr.DirCsRoot;
3026

3127
#if UNITY_EDITOR
3228
// 检测Script.CSharp.dll是否存在,如不存在则给出提示
@@ -41,24 +37,29 @@ void LoadHotFixAssembly()
4137
{
4238
AppDomain.LoadAssembly(fs, p, new ILRuntime.Mono.Cecil.Pdb.PdbReaderProvider());
4339

44-
InitializeILRuntime();
40+
// 这里做一些ILRuntime的注册
41+
LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(AppDomain);
42+
CLRBindings.Initialize(AppDomain);
4543

46-
OnHotFixLoaded();
44+
AppDomain.Invoke("CsMain", "Create", null, null);
4745
}
4846
}
4947
}
5048

5149
//-------------------------------------------------------------------------
52-
void InitializeILRuntime()
50+
public void Destroy()
5351
{
54-
// 这里做一些ILRuntime的注册
55-
LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(AppDomain);
56-
CLRBindings.Initialize(AppDomain);
52+
return;
53+
54+
AppDomain.Invoke("CsMain", "Destroy", null, null);
55+
CLRBindings.Shutdown(AppDomain);
5756
}
5857

5958
//-------------------------------------------------------------------------
60-
void OnHotFixLoaded()
59+
public void Update()
6160
{
62-
AppDomain.Invoke("CsMain", "Launch", null, null);
61+
return;
62+
63+
AppDomain.Invoke("CsMain", "Update", null, null);
6364
}
6465
}

Assets/Script/Main/PathMgr.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class PathMgr
3434
public DirType DirLaunchAbType { get; set; }// Resources.KingTexasLaunch目录类型,需动态计算
3535
public string DirLuaRoot { get; set; }// Lua/目录,需动态计算
3636
public string DirRawRoot { get; set; }// Raw/,需动态计算
37+
public string DirCsRoot { get; set; }// Cs/,需动态计算
3738
public string DirAbRoot { get; set; }// "Resources.KingTexas/",需动态计算
3839
public string DirAbUi { get; set; }// "Resources.KingTexas/Ui/",需动态计算
3940
public string DirAbCard { get; set; }// "Resources.KingTexas/Cards/",需动态计算

DataOss/Common/CommonFileList.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
Lua/Lua ED63824133B41E4FC8D681D7EB764E25
2-
Lua/Lua.manifest C4DF85BB7C97D081835675D032D38044
3-
Lua/lua_android.ab ED548D54A51DD909E5C3EFF3B36B0254
4-
Lua/lua_android.ab.manifest 1693EC8A4B1F4AC31B55C05164F30E1A
5-
Lua/lua_launch_android.ab F6700E372F5EB721121A80DA002FF628
6-
Lua/lua_launch_android.ab.manifest C2B39FB6AAA03A871DF157B89408C7A5
1+
Cs/Script.CSharp.dll C2B1F7678ABBBA901881B0177386EA03
2+
Cs/Script.CSharp.pdb DD5C570E005400AF2CCF07C959341702
3+
Lua/Lua 4713F2CCDDCCBA9C82B5267332849886
4+
Lua/Lua.manifest 335511E4896930E28FF2B3917ACA0F0F
5+
Lua/lua_android.ab 1ABCD92CEA32EF10F72FF74A0607B75A
6+
Lua/lua_android.ab.manifest 93A280B4EF51E15E4965C1B1698D81A4
7+
Lua/lua_launch_android.ab BE90531A349EA6640F4B86B1B3C73B73
8+
Lua/lua_launch_android.ab.manifest 6950D45942E7AFAA6F9FAE3D4DFD1942
79
Raw/Icon/ShareIcon.png 22F237826CAE1FEB0825808D1277CB28
810
Raw/TbData/KingClient.db 444B8430FD358413060B67C208A39308
911
Raw/TbData/KingCommon.db 326C34DD7877B52C621A0EF9A687FF94
5 KB
Binary file not shown.
19.5 KB
Binary file not shown.

DataOss/Common/Lua/Lua

0 Bytes
Binary file not shown.

DataOss/Common/Lua/Lua.manifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ManifestFileVersion: 0
2-
CRC: 763375712
2+
CRC: 2640100318
33
AssetBundleManifest:
44
AssetBundleInfos:
55
Info_0:

0 commit comments

Comments
 (0)