private static void refreshData() { m_Config = XConfig.GetConfig <XILRTConfig>(XILConst.ConfigPath_Resources, AssetLoadType.Resources, false); if (m_Config != null) { m_Config_SerObj = new SerializedObject(m_Config); } m_DataRefreshed = true; }
/* * 启动顺序: * - 注册CLR重定向 * - 注册委托适配器 * - 注册跨域适配器 * - 注册CLR绑定 * - 加载Assembly和它的小伙伴们 * */ public async Task <XException> StartAsync() { if (m_Inited) { return(null); } m_Config = XConfig.GetConfig <XILRTConfig>(XILConst.ConfigPath_Resources); if (m_Config == null) { return(new XILRTException("Config file not found :" + XILConst.ConfigPath_Resources)); } if (!m_Config.Enable) { return(null); } //注册CLR重定向 registerCLRMethodRedirections(); //注册委托适配器 registerDelegates(); //注册跨域适配器 registerCrossBindingAdaptors(); //注册CLR绑定 registerGeneratorCLRBindingCode(); //加载Assemblies var e_load = await this.loadAssemblies(m_Config.LoadAssemblies); if (e_load != null) { return(e_load); } m_Inited = true; return(null); }
public static SettingsProvider XILRuntimeSetting() { return(new SettingsProvider(XILEditorConst.ProjectSetting_Node, SettingsScope.Project, new string[] { "Nekonya", "TinaX", "ILRuntime", "TinaX.ILRuntime", "XILRuntime" }) { label = "X ILRuntime", guiHandler = (searchContent) => { if (!m_DataRefreshed) { refreshData(); } EditorGUILayout.BeginVertical(Styles.body); if (m_Config == null) { GUILayout.Space(20); GUILayout.Label(I18Ns.NoConfig); if (GUILayout.Button(I18Ns.BtnCreateConfigFile, Styles.style_btn_normal, GUILayout.MaxWidth(120))) { m_Config = XConfig.CreateConfigIfNotExists <XILRTConfig>(XILConst.ConfigPath_Resources, AssetLoadType.Resources); refreshData(); } } else { GUILayout.Space(10); EditorGUILayout.PropertyField(m_Config_SerObj.FindProperty("Enable"), new GUIContent(I18Ns.Enable)); GUILayout.Space(10); if (m_list_assemblies == null) { m_list_assemblies = new ReorderableList(m_Config_SerObj, m_Config_SerObj.FindProperty("LoadAssemblies"), true, //drag true, true, true); m_list_assemblies.elementHeightCallback = (index) => { float single_line_height = EditorGUIUtility.singleLineHeight + 2; return single_line_height * 2 + 2; }; m_list_assemblies.drawElementCallback = (rect, index, isActive, isFocused) => { rect.y += 2; rect.height = EditorGUIUtility.singleLineHeight; var singleLine = EditorGUIUtility.singleLineHeight + 2; SerializedProperty itemData = m_list_assemblies.serializedProperty.GetArrayElementAtIndex(index); SerializedProperty item_assembly = itemData.FindPropertyRelative("AssemblyPath"); SerializedProperty item_symbol = itemData.FindPropertyRelative("SymbolPath"); var rect_assembly = rect; EditorGUI.PropertyField(rect_assembly, item_assembly); var rect_symbol = rect; rect_symbol.y += singleLine; EditorGUI.PropertyField(rect_symbol, item_symbol); }; m_list_assemblies.drawHeaderCallback = rect => { EditorGUI.LabelField(rect, I18Ns.AssemblyLoadList); }; } m_list_assemblies.DoLayoutList(); GUILayout.Space(10); EditorGUILayout.PropertyField(m_Config_SerObj.FindProperty("EntryClass"), new GUIContent(I18Ns.EntryClass)); EditorGUILayout.PropertyField(m_Config_SerObj.FindProperty("EntryMethod"), new GUIContent(I18Ns.EntryMethod_MethodName)); GUILayout.Space(3); EditorGUILayout.HelpBox(I18Ns.EntryTips, MessageType.None); GUILayout.Space(20); EditorGUILayout.HelpBox(I18Ns.Tips_ConnotHotFix, MessageType.Warning); GUILayout.Space(35); TinaXEditor.Utils.EditorGUIUtil.HorizontalLine(); //CLR生成代码输出 GUILayout.Space(10); EditorGUILayout.LabelField(I18Ns.GenCodeOutputPath); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(m_Config_SerObj.FindProperty("EditorCLRBindingCodeOutputPath"), GUIContent.none); if (GUILayout.Button("Select", Styles.style_btn_normal, GUILayout.Width(65))) { var path = EditorUtility.OpenFolderPanel("Select CLR BindingOutputFolder", "Assets/", ""); if (!path.IsNullOrEmpty()) { var root_path = Directory.GetCurrentDirectory().Replace("\\", "/"); if (path.StartsWith(root_path)) { path = path.Substring(root_path.Length + 1, path.Length - root_path.Length - 1); path = path.Replace("\\", "/"); m_Config_SerObj.FindProperty("EditorCLRBindingCodeOutputPath").stringValue = path; } else { Debug.LogError("Invalid Path: " + path); } } } EditorGUILayout.EndHorizontal(); GUILayout.Space(10); if (m_list_assemblies_editor == null) { m_list_assemblies_editor = new ReorderableList(m_Config_SerObj, m_Config_SerObj.FindProperty("EditorLoadAssemblyPaths"), true, //drag true, true, true); m_list_assemblies_editor.elementHeightCallback = (index) => { float single_line_height = EditorGUIUtility.singleLineHeight + 2; return single_line_height * 2 + 2; }; m_list_assemblies_editor.drawElementCallback = (rect, index, isActive, isFocused) => { rect.y += 2; rect.height = EditorGUIUtility.singleLineHeight; var singleLine = EditorGUIUtility.singleLineHeight + 2; SerializedProperty itemData = m_list_assemblies_editor.serializedProperty.GetArrayElementAtIndex(index); SerializedProperty item_assembly = itemData.FindPropertyRelative("AssemblyPath"); SerializedProperty item_symbol = itemData.FindPropertyRelative("SymbolPath"); var rect_assembly = rect; EditorGUI.PropertyField(rect_assembly, item_assembly); var rect_symbol = rect; rect_symbol.y += singleLine; EditorGUI.PropertyField(rect_symbol, item_symbol); }; m_list_assemblies_editor.drawHeaderCallback = rect => { EditorGUI.LabelField(rect, I18Ns.AssemblyLoadListEditor); }; } m_list_assemblies_editor.DoLayoutList(); GUILayout.Space(5); EditorGUILayout.HelpBox(I18Ns.AssemblyLoadListEditorTips, MessageType.Info); } EditorGUILayout.EndVertical(); if (m_Config_SerObj != null) { m_Config_SerObj.ApplyModifiedProperties(); } }, deactivateHandler = () => { if (m_Config != null) { EditorUtility.SetDirty(m_Config); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } }, }); }