mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-23 17:30:10 +00:00
修复XCharts本地开启TextMeshPro和 NewInputSystem后更新版本会报错的问题 (#272)
This commit is contained in:
@@ -5,9 +5,9 @@ using XCharts.Runtime;
|
||||
|
||||
namespace XCharts.Editor
|
||||
{
|
||||
internal static class ThemeCheck
|
||||
internal static class XChartsDaemon
|
||||
{
|
||||
public class ThemeAssetPostprocessor : AssetPostprocessor
|
||||
public class XChartsAssetPostprocessor : AssetPostprocessor
|
||||
{
|
||||
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets,
|
||||
string[] movedFromAssetsPaths)
|
||||
@@ -28,17 +28,36 @@ namespace XCharts.Editor
|
||||
var fileName = Path.GetFileName(assetPath);
|
||||
if (fileName.Equals("XCSettings.asset"))
|
||||
{
|
||||
CheckAsmdef();
|
||||
XCThemeMgr.ReloadThemeList();
|
||||
return;
|
||||
}
|
||||
if (!IsThemeAsset(assetPath)) return;
|
||||
var theme = AssetDatabase.LoadAssetAtPath<Theme>(assetPath);
|
||||
if (XCSettings.AddCustomTheme(theme))
|
||||
else if (IsThemeAsset(assetPath))
|
||||
{
|
||||
XCThemeMgr.ReloadThemeList();
|
||||
var theme = AssetDatabase.LoadAssetAtPath<Theme>(assetPath);
|
||||
if (XCSettings.AddCustomTheme(theme))
|
||||
{
|
||||
XCThemeMgr.ReloadThemeList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void CheckAsmdef()
|
||||
{
|
||||
#if UNITY_2017_1_OR_NEWER
|
||||
#if dUI_TextMeshPro
|
||||
XChartsEditor.CheckAsmdefTmpReference(true);
|
||||
#else
|
||||
XChartsEditor.CheckAsmdefTmpReference(false);
|
||||
#endif
|
||||
#elif UNITY_2019_1_OR_NEWER
|
||||
#if INPUT_SYSTEM_ENABLED
|
||||
XChartsEditor.CheckAsmdefInputSystemReference(true);
|
||||
#else
|
||||
XChartsEditor.CheckAsmdefInputSystemReference(false);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void CheckDeletedAsset(string assetPath)
|
||||
{
|
||||
if (!IsThemeAsset(assetPath)) return;
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b4ba2a9503ae46b1b7b1ae94ec59127
|
||||
guid: 036a714dab7744d76849114f5bcf59a9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -199,7 +199,9 @@ namespace XCharts.Editor
|
||||
const string SYMBOL_TMP = "dUI_TextMeshPro";
|
||||
const string ASMDEF_TMP = "Unity.TextMeshPro";
|
||||
|
||||
#if !dUI_TextMeshPro
|
||||
[MenuItem("XCharts/TextMeshPro Enable")]
|
||||
#endif
|
||||
public static void EnableTextMeshPro()
|
||||
{
|
||||
if (!IsSpecifyAssemblyExist(ASMDEF_TMP))
|
||||
@@ -207,19 +209,39 @@ namespace XCharts.Editor
|
||||
Debug.LogError("TextMeshPro is not in the project, please import TextMeshPro package first.");
|
||||
return;
|
||||
}
|
||||
DefineSymbolsUtil.AddGlobalDefine(SYMBOL_TMP);
|
||||
XChartsMgr.RemoveAllChartObject();
|
||||
InsertSpecifyReferenceIntoAssembly(Platform.Editor, ASMDEF_TMP);
|
||||
InsertSpecifyReferenceIntoAssembly(Platform.Runtime, ASMDEF_TMP);
|
||||
if (EditorUtility.DisplayDialog("TextMeshPro Enable", "TextMeshPro is disabled, do you want to enable it?", "Yes", "Cancel"))
|
||||
{
|
||||
DefineSymbolsUtil.AddGlobalDefine(SYMBOL_TMP);
|
||||
XChartsMgr.RemoveAllChartObject();
|
||||
CheckAsmdefTmpReference(true);
|
||||
}
|
||||
}
|
||||
|
||||
#if dUI_TextMeshPro
|
||||
[MenuItem("XCharts/TextMeshPro Disable")]
|
||||
#endif
|
||||
public static void DisableTextMeshPro()
|
||||
{
|
||||
RemoveSpecifyReferenceFromAssembly(Platform.Editor, ASMDEF_TMP);
|
||||
RemoveSpecifyReferenceFromAssembly(Platform.Runtime, ASMDEF_TMP);
|
||||
DefineSymbolsUtil.RemoveGlobalDefine(SYMBOL_TMP);
|
||||
XChartsMgr.RemoveAllChartObject();
|
||||
if (EditorUtility.DisplayDialog("TextMeshPro Disable", "TextMeshPro is enabled, do you want to disable it?", "Yes", "Cancel"))
|
||||
{
|
||||
CheckAsmdefTmpReference(false);
|
||||
DefineSymbolsUtil.RemoveGlobalDefine(SYMBOL_TMP);
|
||||
XChartsMgr.RemoveAllChartObject();
|
||||
}
|
||||
}
|
||||
|
||||
public static void CheckAsmdefTmpReference(bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
InsertSpecifyReferenceIntoAssembly(Platform.Editor, ASMDEF_TMP);
|
||||
InsertSpecifyReferenceIntoAssembly(Platform.Runtime, ASMDEF_TMP);
|
||||
}
|
||||
else
|
||||
{
|
||||
RemoveSpecifyReferenceFromAssembly(Platform.Editor, ASMDEF_TMP);
|
||||
RemoveSpecifyReferenceFromAssembly(Platform.Runtime, ASMDEF_TMP);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
@@ -229,7 +251,10 @@ namespace XCharts.Editor
|
||||
//As InputSystem is released in 2019.1+ ,when unity version is 2019.1+ , enable InputSystem Support
|
||||
const string SYMBOL_I_S = "INPUT_SYSTEM_ENABLED";
|
||||
const string ASMDEF_I_S = "Unity.InputSystem";
|
||||
|
||||
#if !INPUT_SYSTEM_ENABLED
|
||||
[MenuItem("XCharts/InputSystem Enable")]
|
||||
#endif
|
||||
public static void EnableInputSystem()
|
||||
{
|
||||
if (!IsSpecifyAssemblyExist(ASMDEF_I_S))
|
||||
@@ -237,20 +262,37 @@ namespace XCharts.Editor
|
||||
Debug.LogError("InputSystem is not in the project, please import InputSystem package first.");
|
||||
return;
|
||||
}
|
||||
// insert input system package into editor and runtime assembly
|
||||
InsertSpecifyReferenceIntoAssembly(Platform.Editor, ASMDEF_I_S);
|
||||
InsertSpecifyReferenceIntoAssembly(Platform.Runtime, ASMDEF_I_S);
|
||||
// add scripting define symbols
|
||||
DefineSymbolsUtil.AddGlobalDefine(SYMBOL_I_S);
|
||||
if (EditorUtility.DisplayDialog("InputSystem Enable", "InputSystem is disabled, do you want to enable it?", "Yes", "Cancel"))
|
||||
{
|
||||
CheckAsmdefInputSystemReference(true);
|
||||
DefineSymbolsUtil.AddGlobalDefine(SYMBOL_I_S);
|
||||
}
|
||||
}
|
||||
|
||||
#if INPUT_SYSTEM_ENABLED
|
||||
[MenuItem("XCharts/InputSystem Disable")]
|
||||
#endif
|
||||
public static void DisableInputSystem()
|
||||
{
|
||||
// remove input system package into editor and runtime assembly
|
||||
RemoveSpecifyReferenceFromAssembly(Platform.Editor, ASMDEF_I_S);
|
||||
RemoveSpecifyReferenceFromAssembly(Platform.Runtime, ASMDEF_I_S);
|
||||
// remove scripting define symbols
|
||||
DefineSymbolsUtil.RemoveGlobalDefine(SYMBOL_I_S);
|
||||
if (EditorUtility.DisplayDialog("InputSystem Disable", "InputSystem is enabled, do you want to disable it?", "Yes", "Cancel"))
|
||||
{
|
||||
CheckAsmdefInputSystemReference(false);
|
||||
DefineSymbolsUtil.RemoveGlobalDefine(SYMBOL_I_S);
|
||||
}
|
||||
}
|
||||
|
||||
public static void CheckAsmdefInputSystemReference(bool enable)
|
||||
{
|
||||
if(enable)
|
||||
{
|
||||
InsertSpecifyReferenceIntoAssembly(Platform.Editor, ASMDEF_I_S);
|
||||
InsertSpecifyReferenceIntoAssembly(Platform.Runtime, ASMDEF_I_S);
|
||||
}
|
||||
else
|
||||
{
|
||||
RemoveSpecifyReferenceFromAssembly(Platform.Editor, ASMDEF_I_S);
|
||||
RemoveSpecifyReferenceFromAssembly(Platform.Runtime, ASMDEF_I_S);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
{
|
||||
"name": "XCharts.Editor",
|
||||
"references": [
|
||||
"XCharts.Runtime"
|
||||
"XCharts.Runtime",
|
||||
"Unity.TextMeshPro",
|
||||
"Unity.InputSystem"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
|
||||
Reference in New Issue
Block a user