/// <summary> /// 初始化框架编辑器 /// </summary> static public void InitEditorEnvironment() { //是否为batchmode if (Application.isBatchMode) { Debug.Log("BDFramework version:" + BDLauncher.Version); } //只有在非Playing的时候才初始化 if (EditorApplication.isPlayingOrWillChangePlaymode || IsInited) { return; } try { //BD初始化 BApplication.Init(); //BDEditor初始化 BDEditorApplication.Init(); //加载主工程的DLL Type var assemblyPath = BApplication.Library + "/ScriptAssemblies/Assembly-CSharp.dll"; var editorAssemlyPath = BApplication.Library + "/ScriptAssemblies/Assembly-CSharp-Editor.dll"; if (File.Exists(assemblyPath) && File.Exists(editorAssemlyPath)) { var gAssembly = Assembly.LoadFile(assemblyPath); var eAssemlby = Assembly.LoadFile(editorAssemlyPath); Types = CollectTypes(gAssembly, eAssemlby).ToArray(); } //编辑器下加载初始化 BResources.Init(AssetLoadPathType.Editor); //编辑器下管理器注册 ManagerInstHelper.Load(Types); //Editor的管理器初始化 BDFrameworkPipelineHelper.Init(); //调试器启动 DebuggerServerProcessManager.Inst.Start(); //Pipeline初始化 HotfixPipelineTools.Init(); //编辑器初始化 InitEditorTask(); EditorTaskInstance.OnUnityLoadOrCodeRecompiled(); //最后,完成初始化 IsInited = true; // Debug.Log("框架编辑器环境初始化成功!"); } catch (Exception e) { Debug.LogError("框架编辑器环境初始化失败!"); Debug.LogError(e); throw; } }
static public void BDEditorInit() { #region 注册所以管理器,让管理器在编辑器下生效 //项目所有类 var types = typeof(BDLauncher).Assembly.GetTypes().ToList(); //编辑器所有类 var editorTypes = typeof(BDEditorMenuEnum).Assembly.GetTypes(); types.AddRange(editorTypes); List <IMgr> mgrs = new List <IMgr>(); foreach (var t in types) { if (t != null && t.BaseType != null && t.BaseType.FullName != null && t.BaseType.FullName.Contains(".ManagerBase`2")) { var i = t.BaseType.GetProperty("Inst").GetValue(null, null) as IMgr; mgrs.Add(i); continue; } } foreach (var t in types) { foreach (var mgr in mgrs) { mgr.CheckType(t); } } Debug.Log("BDFrameEditor:管理器注册完成"); #endregion BApplication.Init(); DebuggerServerProcessManager.Inst.Start(); BDEditorHelper.Init(); BResources.Load(""); //TODO //这一行还是不能加到框架层,应该还是:哪里用 哪里主动load, //然后用完了close(SqliteLoder.Close())。 //不然sql文件editor环境下一直被占用,很多麻烦事 // SqliteLoder.Load(Application.streamingAssetsPath); }