From 536d04af5b638a04efb46f93214b7f9ac73af875 Mon Sep 17 00:00:00 2001
From: client_linchunjie <461730578@qq.com>
Date: 星期六, 10 十一月 2018 10:12:53 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.0.87:10010/r/snxxz_scripts
---
System/WindowBase/ModelCenter.cs | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/System/WindowBase/ModelCenter.cs b/System/WindowBase/ModelCenter.cs
index 41a7893..90bf2ae 100644
--- a/System/WindowBase/ModelCenter.cs
+++ b/System/WindowBase/ModelCenter.cs
@@ -52,11 +52,13 @@
void OnSwitchAccount();
}
+ [XLua.LuaCallCSharp]
public class ModelCenter : Singleton<ModelCenter>
{
bool inited = false;
Dictionary<int, Model> models = new Dictionary<int, Model>();
+ Dictionary<string, Model> nameToModels = new Dictionary<string, Model>();
public ModelCenter()
{
@@ -223,15 +225,27 @@
return model;
}
+ public Model GetModel(string name)
+ {
+ if (nameToModels.ContainsKey(name))
+ {
+ return nameToModels[name];
+ }
+
+ return null;
+ }
+
T RegisterModel<T>() where T : Model, new()
{
T model = null;
var token = typeof(T).MetadataToken;
+ var name = typeof(T).Name;
if (!models.ContainsKey(token))
{
model = new T();
models[token] = model;
+ nameToModels[name] = model;
model.Init();
}
--
Gitblit v1.8.0