From ea0d3391d2bdfe9fc2668b7ab6f069b62cb90cb7 Mon Sep 17 00:00:00 2001 From: ialex32x Date: Wed, 27 Oct 2021 18:11:49 +0800 Subject: [PATCH] seperate jsb assemblies from assemblies of project with asmdef --- .../InMemoryCompilationBindingCallback.cs | 117 +++++++++++++++++- .../Source/Binding/Editor/IBindingUtils.cs | 62 ++++------ .../Binding/Editor/jsb.editor.binding.asmdef | 17 +++ .../Editor/jsb.editor.binding.asmdef.meta | 7 ++ Assets/jsb/Source/Unity/Editor/PrefsEditor.cs | 7 +- .../Source/Unity/Editor/UnityBindingUtils.cs | 20 +++ .../Unity/Editor/UnityBindingUtils.cs.meta | 11 ++ Assets/jsb/Source/Unity/Editor/UnityHelper.cs | 115 +---------------- .../Unity/Editor/jsb.editor.unity.asmdef | 18 +++ .../Unity/Editor/jsb.editor.unity.asmdef.meta | 7 ++ .../Hotfix/Editor/jsb.editor.hotfix.asmdef | 19 +++ .../Editor/jsb.editor.hotfix.asmdef.meta | 7 ++ .../jsb/Source/Utils/DefaultJsonConverter.cs | 66 +++++----- Assets/jsb/Source/jsb.core.asmdef | 13 ++ Assets/jsb/Source/jsb.core.asmdef.meta | 7 ++ 15 files changed, 311 insertions(+), 182 deletions(-) create mode 100644 Assets/jsb/Source/Binding/Editor/jsb.editor.binding.asmdef create mode 100644 Assets/jsb/Source/Binding/Editor/jsb.editor.binding.asmdef.meta create mode 100644 Assets/jsb/Source/Unity/Editor/UnityBindingUtils.cs create mode 100644 Assets/jsb/Source/Unity/Editor/UnityBindingUtils.cs.meta create mode 100644 Assets/jsb/Source/Unity/Editor/jsb.editor.unity.asmdef create mode 100644 Assets/jsb/Source/Unity/Editor/jsb.editor.unity.asmdef.meta create mode 100644 Assets/jsb/Source/Unity/Hotfix/Editor/jsb.editor.hotfix.asmdef create mode 100644 Assets/jsb/Source/Unity/Hotfix/Editor/jsb.editor.hotfix.asmdef.meta create mode 100644 Assets/jsb/Source/jsb.core.asmdef create mode 100644 Assets/jsb/Source/jsb.core.asmdef.meta diff --git a/Assets/jsb/Source/Binding/Editor/BindingCallback/InMemoryCompilationBindingCallback.cs b/Assets/jsb/Source/Binding/Editor/BindingCallback/InMemoryCompilationBindingCallback.cs index 5077c65e..b8fd03ff 100644 --- a/Assets/jsb/Source/Binding/Editor/BindingCallback/InMemoryCompilationBindingCallback.cs +++ b/Assets/jsb/Source/Binding/Editor/BindingCallback/InMemoryCompilationBindingCallback.cs @@ -17,6 +17,119 @@ public class InMemoryCompilationBindingCallback : IBindingCallback, ICodeGenCall private List _generatedAssemblies = new List(); private string _compilerOptions; + public static List GetDefinedSymbols() + { + var defines = new List(); + +#if UNITY_EDITOR // #define directive to call Unity Editor scripts from your game code. + defines.Add("UNITY_EDITOR"); +#endif +#if UNITY_EDITOR_WIN // #define directive for Editor code on Windows. + defines.Add("UNITY_EDITOR_WIN"); +#endif +#if UNITY_EDITOR_OSX // #define directive for Editor code on Mac OS X. + defines.Add("UNITY_EDITOR_OSX"); +#endif +#if UNITY_EDITOR_LINUX // #define directive for Editor code on Linux. + defines.Add("UNITY_EDITOR_LINUX"); +#endif +#if UNITY_STANDALONE_OSX // #define directive to compile or execute code specifically for Mac OS X (including Universal, PPC and Intel architectures). + defines.Add("UNITY_STANDALONE_OSX"); +#endif +#if UNITY_STANDALONE_WIN // #define directive for compiling/executing code specifically for Windows standalone applications. + defines.Add("UNITY_STANDALONE_WIN"); +#endif +#if UNITY_STANDALONE_LINUX // #define directive for compiling/executing code specifically for Linux standalone applications. + defines.Add("UNITY_STANDALONE_LINUX"); +#endif +#if UNITY_STANDALONE // #define directive for compiling/executing code for any standalone platform (Mac OS X, Windows or Linux). + defines.Add("UNITY_STANDALONE"); +#endif +#if UNITY_WII // #define directive for compiling/executing code for the Wii console. + defines.Add("UNITY_WII"); +#endif +#if UNITY_IOS // #define directive for compiling/executing code for the iOS platform. + defines.Add("UNITY_IOS"); +#endif +#if UNITY_IPHONE // Deprecated. Use UNITY_IOS instead. + defines.Add("UNITY_IPHONE"); +#endif +#if UNITY_ANDROID // #define directive for the Android platform. + defines.Add("UNITY_ANDROID"); +#endif +#if UNITY_PS4 // #define directive for running PlayStation 4 code. + defines.Add("UNITY_PS4"); +#endif +#if UNITY_XBOXONE // #define directive for executing Xbox One code. + defines.Add("UNITY_XBOXONE"); +#endif +#if UNITY_LUMIN // #define directive for the Magic Leap OS platform. You can also use PLATFORM_LUMIN. + defines.Add("UNITY_LUMIN"); +#endif +#if UNITY_TIZEN // #define directive for the Tizen platform. + defines.Add("UNITY_TIZEN"); +#endif +#if UNITY_TVOS // #define directive for the Apple TV platform. + defines.Add("UNITY_TVOS"); +#endif +#if UNITY_WSA // #define directive for Universal Windows Platform + defines.Add("UNITY_WSA"); +#endif +#if UNITY_WSA_10_0 // #define directive for Universal Windows Platform. Additionally WINDOWS_UWP is defined when compiling C# files against .NET Core. + defines.Add("UNITY_WSA_10_0"); +#endif +#if UNITY_WINRT // Same as UNITY_WSA. + defines.Add("UNITY_WINRT"); +#endif +#if UNITY_WINRT_10_0 // Equivalent to UNITY_WSA_10_0 + defines.Add("UNITY_WINRT_10_0"); +#endif +#if UNITY_WEBGL // #define directive for WebGL + defines.Add("UNITY_WEBGL"); +#endif +#if UNITY_FACEBOOK // #define directive for the Facebook platform (WebGL or Windows standalone). + defines.Add("UNITY_FACEBOOK"); +#endif +#if UNITY_ANALYTICS // #define directive for calling Unity Analytics + defines.Add("UNITY_ANALYTICS"); +#endif +#if UNITY_ASSERTIONS // #define directive for assertions control process. + defines.Add("UNITY_ASSERTIONS"); +#endif +#if UNITY_64 // #define directive for 64-bit platforms. + defines.Add("UNITY_64"); +#endif +#if UNITY_SERVER + defines.Add("UNITY_SERVER"); +#endif + return defines; + } + +#if !JSB_UNITYLESS && UNITY_EDITOR + public static UnityEditor.BuildTargetGroup GetBuildTargetGroup() + { + var buildTarget = UnityEditor.EditorUserBuildSettings.activeBuildTarget; + switch (buildTarget) + { + case UnityEditor.BuildTarget.Android: return UnityEditor.BuildTargetGroup.Android; + case UnityEditor.BuildTarget.iOS: return UnityEditor.BuildTargetGroup.iOS; + case UnityEditor.BuildTarget.WSAPlayer: return UnityEditor.BuildTargetGroup.WSA; +#if !UNITY_2019_2_OR_NEWER + case UnityEditor.BuildTarget.StandaloneLinux: + case UnityEditor.BuildTarget.StandaloneLinuxUniversal: +#endif + case UnityEditor.BuildTarget.StandaloneLinux64: + case UnityEditor.BuildTarget.StandaloneOSX: + case UnityEditor.BuildTarget.StandaloneWindows: + case UnityEditor.BuildTarget.StandaloneWindows64: return UnityEditor.BuildTargetGroup.Standalone; + case UnityEditor.BuildTarget.Switch: return UnityEditor.BuildTargetGroup.Switch; + case UnityEditor.BuildTarget.PS4: return UnityEditor.BuildTargetGroup.PS4; + case UnityEditor.BuildTarget.XboxOne: return UnityEditor.BuildTargetGroup.XboxOne; + } + throw new NotImplementedException(); + } +#endif + public InMemoryCompilationBindingCallback(ScriptRuntime runtime) { _runtime = runtime; @@ -26,13 +139,13 @@ public InMemoryCompilationBindingCallback(ScriptRuntime runtime) var compilerOptions = "-unsafe"; #if !JSB_UNITYLESS - symbolList.AddRange(Unity.UnityHelper.GetDefinedSymbols()); + symbolList.AddRange(GetDefinedSymbols()); #endif defines += string.Join(";", symbolList); #if !JSB_UNITYLESS && UNITY_EDITOR - var customDefinedSymbols = UnityEditor.PlayerSettings.GetScriptingDefineSymbolsForGroup(Unity.UnityHelper.GetBuildTargetGroup()); + var customDefinedSymbols = UnityEditor.PlayerSettings.GetScriptingDefineSymbolsForGroup(GetBuildTargetGroup()); if (!string.IsNullOrEmpty(customDefinedSymbols)) { defines += ";" + customDefinedSymbols; diff --git a/Assets/jsb/Source/Binding/Editor/IBindingUtils.cs b/Assets/jsb/Source/Binding/Editor/IBindingUtils.cs index 7c2acec1..7f8007f8 100644 --- a/Assets/jsb/Source/Binding/Editor/IBindingUtils.cs +++ b/Assets/jsb/Source/Binding/Editor/IBindingUtils.cs @@ -1,36 +1,28 @@ -using System; -using System.IO; -using System.Collections.Generic; -using System.Reflection; - -namespace QuickJS.Binding -{ - public interface IBindingUtils - { - string ReplacePathVars(string value); - - bool IsExplicitEditorType(Type type); - } - - public class DefaultBindingUtils : IBindingUtils - { - public string ReplacePathVars(string value) - { -#if JSB_UNITYLESS - value = value.Replace("${platform}", "unityless"); - return value; -#else - return Unity.UnityHelper.ReplacePathVars(value); -#endif - } - - public bool IsExplicitEditorType(Type type) - { -#if JSB_UNITYLESS - return false; -#else - return Unity.UnityHelper.IsExplicitEditorType(type); -#endif - } - } +using System; +using System.IO; +using System.Collections.Generic; +using System.Reflection; + +namespace QuickJS.Binding +{ + public interface IBindingUtils + { + string ReplacePathVars(string value); + + bool IsExplicitEditorType(Type type); + } + + public class DefaultBindingUtils : IBindingUtils + { + public string ReplacePathVars(string value) + { + value = value.Replace("${platform}", "unityless"); + return value; + } + + public bool IsExplicitEditorType(Type type) + { + return false; + } + } } \ No newline at end of file diff --git a/Assets/jsb/Source/Binding/Editor/jsb.editor.binding.asmdef b/Assets/jsb/Source/Binding/Editor/jsb.editor.binding.asmdef new file mode 100644 index 00000000..cc2aedaa --- /dev/null +++ b/Assets/jsb/Source/Binding/Editor/jsb.editor.binding.asmdef @@ -0,0 +1,17 @@ +{ + "name": "jsb.editor.binding", + "references": [ + "GUID:118b4ca3a1852354bac065cf952c1e85" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": true, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Assets/jsb/Source/Binding/Editor/jsb.editor.binding.asmdef.meta b/Assets/jsb/Source/Binding/Editor/jsb.editor.binding.asmdef.meta new file mode 100644 index 00000000..27ec5db6 --- /dev/null +++ b/Assets/jsb/Source/Binding/Editor/jsb.editor.binding.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: eda0539582471264796e5affb41fe082 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/jsb/Source/Unity/Editor/PrefsEditor.cs b/Assets/jsb/Source/Unity/Editor/PrefsEditor.cs index 3aadc102..3a1e0487 100644 --- a/Assets/jsb/Source/Unity/Editor/PrefsEditor.cs +++ b/Assets/jsb/Source/Unity/Editor/PrefsEditor.cs @@ -449,9 +449,14 @@ protected override void OnEnable() { base.OnEnable(); + var args = new BindingManager.Args() + { + utils = new UnityBindingUtils(), + }; + _prefs = UnityHelper.LoadPrefs(out _filePath); _selectedBindingMethod = Array.IndexOf(_bindingMethodValues, _prefs.preferredBindingMethod); - _bindingManager = new BindingManager(_prefs, new BindingManager.Args()); + _bindingManager = new BindingManager(_prefs, args); _bindingManager.Collect(); _bindingManager.Generate(TypeBindingFlags.None); _bindingManager.Report(); diff --git a/Assets/jsb/Source/Unity/Editor/UnityBindingUtils.cs b/Assets/jsb/Source/Unity/Editor/UnityBindingUtils.cs new file mode 100644 index 00000000..4adf3128 --- /dev/null +++ b/Assets/jsb/Source/Unity/Editor/UnityBindingUtils.cs @@ -0,0 +1,20 @@ +using System; +using System.IO; +using System.Collections.Generic; +using System.Reflection; + +namespace QuickJS.Unity +{ + public class UnityBindingUtils : Binding.IBindingUtils + { + public string ReplacePathVars(string value) + { + return Unity.UnityHelper.ReplacePathVars(value); + } + + public bool IsExplicitEditorType(Type type) + { + return Unity.UnityHelper.IsExplicitEditorType(type); + } + } +} diff --git a/Assets/jsb/Source/Unity/Editor/UnityBindingUtils.cs.meta b/Assets/jsb/Source/Unity/Editor/UnityBindingUtils.cs.meta new file mode 100644 index 00000000..8e92df5f --- /dev/null +++ b/Assets/jsb/Source/Unity/Editor/UnityBindingUtils.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 687b23b93fb78b5429ad5cfb965c731b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/jsb/Source/Unity/Editor/UnityHelper.cs b/Assets/jsb/Source/Unity/Editor/UnityHelper.cs index 52caee83..482353fc 100644 --- a/Assets/jsb/Source/Unity/Editor/UnityHelper.cs +++ b/Assets/jsb/Source/Unity/Editor/UnityHelper.cs @@ -38,6 +38,7 @@ public static void GenerateBindingsAndTypeDefinition() codeGenCallback = new DefaultCodeGenCallback(), bindingLogger = new DefaultBindingLogger(), useLogWriter = true, + utils = new UnityBindingUtils(), }); bm.Collect(); bm.Generate(TypeBindingFlags.Default); @@ -54,6 +55,7 @@ public static void GenerateTypeDefinition() codeGenCallback = new DefaultCodeGenCallback(), bindingLogger = new DefaultBindingLogger(), useLogWriter = true, + utils = new UnityBindingUtils(), }); bm.Collect(); bm.Generate(TypeBindingFlags.TypeDefinition); @@ -129,6 +131,7 @@ public static void InvokeReflectBinding(ScriptRuntime runtime) var bm = new BindingManager(LoadPrefs(), new BindingManager.Args { bindingCallback = new ReflectBindingCallback(runtime), + utils = new UnityBindingUtils(), }); bm.Collect(); bm.Generate(TypeBindingFlags.None); @@ -147,6 +150,7 @@ public static void InvokeInMemoryBinding(ScriptRuntime runtime) { bindingCallback = callback, codeGenCallback = callback, + utils = new UnityBindingUtils(), }); bm.Collect(); bm.Generate(TypeBindingFlags.BindingCode | TypeBindingFlags.BuildTargetPlatformOnly); @@ -235,117 +239,6 @@ public static string GetPlatform() } } - public static BuildTargetGroup GetBuildTargetGroup() - { - var buildTarget = EditorUserBuildSettings.activeBuildTarget; - switch (buildTarget) - { - case BuildTarget.Android: return BuildTargetGroup.Android; - case BuildTarget.iOS: return BuildTargetGroup.iOS; - case BuildTarget.WSAPlayer: return BuildTargetGroup.WSA; -#if !UNITY_2019_2_OR_NEWER - case BuildTarget.StandaloneLinux: - case BuildTarget.StandaloneLinuxUniversal: -#endif - case BuildTarget.StandaloneLinux64: - case BuildTarget.StandaloneOSX: - case BuildTarget.StandaloneWindows: - case BuildTarget.StandaloneWindows64: return BuildTargetGroup.Standalone; - case BuildTarget.Switch: return BuildTargetGroup.Switch; - case BuildTarget.PS4: return BuildTargetGroup.PS4; - case BuildTarget.XboxOne: return BuildTargetGroup.XboxOne; - } - throw new NotImplementedException(); - } - - public static List GetDefinedSymbols() - { - var defines = new List(); - -#if UNITY_EDITOR // #define directive to call Unity Editor scripts from your game code. - defines.Add("UNITY_EDITOR"); -#endif -#if UNITY_EDITOR_WIN // #define directive for Editor code on Windows. - defines.Add("UNITY_EDITOR_WIN"); -#endif -#if UNITY_EDITOR_OSX // #define directive for Editor code on Mac OS X. - defines.Add("UNITY_EDITOR_OSX"); -#endif -#if UNITY_EDITOR_LINUX // #define directive for Editor code on Linux. - defines.Add("UNITY_EDITOR_LINUX"); -#endif -#if UNITY_STANDALONE_OSX // #define directive to compile or execute code specifically for Mac OS X (including Universal, PPC and Intel architectures). - defines.Add("UNITY_STANDALONE_OSX"); -#endif -#if UNITY_STANDALONE_WIN // #define directive for compiling/executing code specifically for Windows standalone applications. - defines.Add("UNITY_STANDALONE_WIN"); -#endif -#if UNITY_STANDALONE_LINUX // #define directive for compiling/executing code specifically for Linux standalone applications. - defines.Add("UNITY_STANDALONE_LINUX"); -#endif -#if UNITY_STANDALONE // #define directive for compiling/executing code for any standalone platform (Mac OS X, Windows or Linux). - defines.Add("UNITY_STANDALONE"); -#endif -#if UNITY_WII // #define directive for compiling/executing code for the Wii console. - defines.Add("UNITY_WII"); -#endif -#if UNITY_IOS // #define directive for compiling/executing code for the iOS platform. - defines.Add("UNITY_IOS"); -#endif -#if UNITY_IPHONE // Deprecated. Use UNITY_IOS instead. - defines.Add("UNITY_IPHONE"); -#endif -#if UNITY_ANDROID // #define directive for the Android platform. - defines.Add("UNITY_ANDROID"); -#endif -#if UNITY_PS4 // #define directive for running PlayStation 4 code. - defines.Add("UNITY_PS4"); -#endif -#if UNITY_XBOXONE // #define directive for executing Xbox One code. - defines.Add("UNITY_XBOXONE"); -#endif -#if UNITY_LUMIN // #define directive for the Magic Leap OS platform. You can also use PLATFORM_LUMIN. - defines.Add("UNITY_LUMIN"); -#endif -#if UNITY_TIZEN // #define directive for the Tizen platform. - defines.Add("UNITY_TIZEN"); -#endif -#if UNITY_TVOS // #define directive for the Apple TV platform. - defines.Add("UNITY_TVOS"); -#endif -#if UNITY_WSA // #define directive for Universal Windows Platform - defines.Add("UNITY_WSA"); -#endif -#if UNITY_WSA_10_0 // #define directive for Universal Windows Platform. Additionally WINDOWS_UWP is defined when compiling C# files against .NET Core. - defines.Add("UNITY_WSA_10_0"); -#endif -#if UNITY_WINRT // Same as UNITY_WSA. - defines.Add("UNITY_WINRT"); -#endif -#if UNITY_WINRT_10_0 // Equivalent to UNITY_WSA_10_0 - defines.Add("UNITY_WINRT_10_0"); -#endif -#if UNITY_WEBGL // #define directive for WebGL - defines.Add("UNITY_WEBGL"); -#endif -#if UNITY_FACEBOOK // #define directive for the Facebook platform (WebGL or Windows standalone). - defines.Add("UNITY_FACEBOOK"); -#endif -#if UNITY_ANALYTICS // #define directive for calling Unity Analytics - defines.Add("UNITY_ANALYTICS"); -#endif -#if UNITY_ASSERTIONS // #define directive for assertions control process. - defines.Add("UNITY_ASSERTIONS"); -#endif -#if UNITY_64 // #define directive for 64-bit platforms. - defines.Add("UNITY_64"); -#endif -#if UNITY_SERVER - defines.Add("UNITY_SERVER"); -#endif - return defines; - } - /// /// 可以明确表明该 Type 属于 Editor 运行时 /// diff --git a/Assets/jsb/Source/Unity/Editor/jsb.editor.unity.asmdef b/Assets/jsb/Source/Unity/Editor/jsb.editor.unity.asmdef new file mode 100644 index 00000000..0901d5c3 --- /dev/null +++ b/Assets/jsb/Source/Unity/Editor/jsb.editor.unity.asmdef @@ -0,0 +1,18 @@ +{ + "name": "jsb.editor.unity", + "references": [ + "GUID:118b4ca3a1852354bac065cf952c1e85", + "GUID:eda0539582471264796e5affb41fe082" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": true, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Assets/jsb/Source/Unity/Editor/jsb.editor.unity.asmdef.meta b/Assets/jsb/Source/Unity/Editor/jsb.editor.unity.asmdef.meta new file mode 100644 index 00000000..533c7ae5 --- /dev/null +++ b/Assets/jsb/Source/Unity/Editor/jsb.editor.unity.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 2746379d15af6e84cbeb433df77dd384 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/jsb/Source/Unity/Hotfix/Editor/jsb.editor.hotfix.asmdef b/Assets/jsb/Source/Unity/Hotfix/Editor/jsb.editor.hotfix.asmdef new file mode 100644 index 00000000..b8d1ec9c --- /dev/null +++ b/Assets/jsb/Source/Unity/Hotfix/Editor/jsb.editor.hotfix.asmdef @@ -0,0 +1,19 @@ +{ + "name": "jsb.editor.hotfix", + "references": [ + "GUID:118b4ca3a1852354bac065cf952c1e85", + "GUID:eda0539582471264796e5affb41fe082", + "GUID:2746379d15af6e84cbeb433df77dd384" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": true, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Assets/jsb/Source/Unity/Hotfix/Editor/jsb.editor.hotfix.asmdef.meta b/Assets/jsb/Source/Unity/Hotfix/Editor/jsb.editor.hotfix.asmdef.meta new file mode 100644 index 00000000..5bd73441 --- /dev/null +++ b/Assets/jsb/Source/Unity/Hotfix/Editor/jsb.editor.hotfix.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: a6213e1ed98b428479613d08aa859f3f +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/jsb/Source/Utils/DefaultJsonConverter.cs b/Assets/jsb/Source/Utils/DefaultJsonConverter.cs index aeaa284c..f48e371c 100644 --- a/Assets/jsb/Source/Utils/DefaultJsonConverter.cs +++ b/Assets/jsb/Source/Utils/DefaultJsonConverter.cs @@ -1,33 +1,33 @@ -using System; - -namespace QuickJS.Utils -{ - public class DefaultJsonConverter : IJsonConverter - { - public object Deserialize(string json, Type type) - { -#if JSB_UNITYLESS -#if JSB_COMPATIBLE - throw new NotImplementedException(); -#else - return System.Text.Json.JsonSerializer.Deserialize(json, type); -#endif -#else - return UnityEngine.JsonUtility.FromJson(json, type); -#endif - } - - public string Serialize(object obj, bool prettyPrint) - { -#if JSB_UNITYLESS -#if JSB_COMPATIBLE - throw new NotImplementedException(); -#else - return System.Text.Json.JsonSerializer.Serialize(obj); -#endif -#else - return UnityEngine.JsonUtility.ToJson(obj, true); -#endif - } - } -} +using System; + +namespace QuickJS.Utils +{ + public class DefaultJsonConverter : IJsonConverter + { + public object Deserialize(string json, Type type) + { +#if JSB_UNITYLESS +#if JSB_COMPATIBLE + throw new NotImplementedException(); +#else + return System.Text.Json.JsonSerializer.Deserialize(json, type); +#endif +#else + return UnityEngine.JsonUtility.FromJson(json, type); +#endif + } + + public string Serialize(object obj, bool prettyPrint) + { +#if JSB_UNITYLESS +#if JSB_COMPATIBLE + throw new NotImplementedException(); +#else + return System.Text.Json.JsonSerializer.Serialize(obj); +#endif +#else + return UnityEngine.JsonUtility.ToJson(obj, true); +#endif + } + } +} diff --git a/Assets/jsb/Source/jsb.core.asmdef b/Assets/jsb/Source/jsb.core.asmdef new file mode 100644 index 00000000..bc2b108b --- /dev/null +++ b/Assets/jsb/Source/jsb.core.asmdef @@ -0,0 +1,13 @@ +{ + "name": "jsb.core", + "references": [], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": true, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Assets/jsb/Source/jsb.core.asmdef.meta b/Assets/jsb/Source/jsb.core.asmdef.meta new file mode 100644 index 00000000..a3fc1f8c --- /dev/null +++ b/Assets/jsb/Source/jsb.core.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 118b4ca3a1852354bac065cf952c1e85 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: