public static void reload() { var types = Assembly.GetAssembly(typeof(App)).GetTypes(); foreach (var type in types) { try { var baseType = type.BaseType; if (baseType != null) { if ("FastNet.Cfg`2".Equals(baseType.Namespace + "." + baseType.Name)) { var method = type.GetMethod("Init", BindingFlags.Public | BindingFlags.Static); method.Invoke(null, null); } } } catch (Exception e) { UnityEngine.Debug.LogException(e); } } if (s_luaEnv != null) { //pkt MessageLua.Load(s_workPath + "/pkt_table.bytes", s_luaEnv); //cfg CfgLua.Load(s_workPath + "/cfg_table.bytes", s_luaEnv); } }
public static void initialize(XLua.LuaEnv luaEnv = null) { try { s_workPath = System.IO.Path.Combine(Application.persistentDataPath, "FastNet"); if (Directory.Exists(s_workPath) == false) { Directory.CreateDirectory(s_workPath); } s_luaEnv = luaEnv; var types = Assembly.GetAssembly(typeof(App)).GetTypes(); foreach (var type in types) { try { var baseType = type.BaseType; if (baseType != null) { if ("FastNet.Cfg`2".Equals(baseType.Namespace + "." + baseType.Name)) { var method = type.GetMethod("Init", BindingFlags.Public | BindingFlags.Static); method.Invoke(null, null); } else if ("FastNet.Message".Equals(baseType.Namespace + "." + baseType.Name)) { RegisterMessage(type, false); } } } catch (Exception e) { UnityEngine.Debug.LogException(e); } } if (luaEnv != null) { //pkt MessageLua.Load(s_workPath + "/pkt_table.bytes", luaEnv); //cfg CfgLua.Load(s_workPath + "/cfg_table.bytes", luaEnv); } } catch (Exception e) { Debug.LogException(e); } }