private static UIElement GetUIElement(PropertyInfo propertyInfo, ISettingsProviderClass settingsProvider) { var settingsService = CheckoutAndBuild2Package.GetGlobalService <SettingsService>(); var attribute = propertyInfo.GetAttributes <SettingsPropertyAttribute>(false).First(); SettingsKey settingsKey = GetSettingsKey(propertyInfo, settingsProvider); object defaultValue = null; DefaultValueAttribute defaultValueAttribute = propertyInfo.GetAttributes <DefaultValueAttribute>(false).FirstOrDefault(); if (defaultValueAttribute != null) { defaultValue = defaultValueAttribute.Value; } return(EditorTemplates.GetUIElement(propertyInfo, settingsService, settingsKey, defaultValue, attribute)); }
public static void Init(Logger log, Properties config) { if (ZoneFactory == null) { log.Info("********************************************************"); log.Info("# 初始化战斗编辑器扩展 "); log.Info("********************************************************"); ZoneFactory = ReflectionUtil.CreateInterface <InstanceZoneFactory>(config["ZoneFactory"]); TemplateManager.SetFactory(ZoneFactory); ZoneServerFactory = ReflectionUtil.CreateInterface <ZoneNodeFactory>(config["ZoneServerFactory"]); log.Info(" 战斗编辑器插件 : " + ZoneFactory); log.Info(" 战斗服务器插件 : " + ZoneServerFactory); } if (NodeConfig == null) { log.Info("********************************************************"); log.Info("# 加载配置文件"); log.Info("********************************************************"); NodeConfig = ZoneServerFactory.GetConfig(); var node_cfg = config.SubProperties("ZoneNodeConfig."); if (node_cfg != null) { node_cfg.LoadFields(NodeConfig); } } if (DataRoot == null) { log.Info("********************************************************"); log.Info("# 加载模板数据"); log.Info("********************************************************"); try { DataRoot = TemplateManager.Factory.CreateEditorTemplates(config["DataRootPath"]); DataRoot.LoadAllTemplates(); DataRoot.CacheAllScenes(); } catch (Exception err) { throw new Exception("EditorTemplates init error : " + err.Message + "\n" + err.StackTrace, err); } log.Info("********************************************************"); } }
/// <summary> /// 初始化所有模板以及工厂类,游戏启动时调用 /// </summary> public void Init(string data_path) { this.data_root = ZoneDataFactory.Factory.CreateEditorTemplates(data_path, true); this.data_root.LoadAllTemplates(); this.battle_codec = new BattleCodec(data_root.Templates); }