From 349877fe7ab2bf3dfe0613d7b0ad56c3158b12a9 Mon Sep 17 00:00:00 2001 From: CortexCore <2630229280@qq.com> Date: Fri, 14 Jun 2024 14:11:28 +0800 Subject: [PATCH] 1 --- Src/Core/Attributes/IBITCommand.cs | 2 +- Src/Core/BITLog/BIT4Log.cs | 2 +- Src/Core/Tween/BITween.cs | 3 +-- Src/Unity/Scripts/Assets/BITFramework.cs | 5 ++++- .../Scripts/UX/ApplicationFile/UXApplicationFile.cs | 2 +- Src/Unity/Scripts/UX/ModService/UXModService.cs | 10 ++++++++++ Src/Unity/Scripts/Utility/Editor/BITInspector.cs | 6 ++++++ Src/Unity/Scripts/Utils/UnityApplicationFile.cs | 8 ++++---- Src/Unity/Scripts/WorldNode/WorldNodeService.cs | 1 - Src/UnityEditor/SceneGizmoReference.cs | 1 - 10 files changed, 28 insertions(+), 12 deletions(-) diff --git a/Src/Core/Attributes/IBITCommand.cs b/Src/Core/Attributes/IBITCommand.cs index 4ce4457..2859d3e 100644 --- a/Src/Core/Attributes/IBITCommand.cs +++ b/Src/Core/Attributes/IBITCommand.cs @@ -53,7 +53,7 @@ namespace BITKit AsGlobal = asGlobal; } } - #if UNITY_64 + #if !Godot [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Field | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] public class ExportAttribute : System.Attribute { diff --git a/Src/Core/BITLog/BIT4Log.cs b/Src/Core/BITLog/BIT4Log.cs index 8dace06..f3d660a 100644 --- a/Src/Core/BITLog/BIT4Log.cs +++ b/Src/Core/BITLog/BIT4Log.cs @@ -8,7 +8,7 @@ namespace BITKit { public static class BIT4Log { - #if UNITY_EDITOR && !UNITY_WEBGL + #if UNITY_EDITOR && UNITY_64 [RuntimeInitializeOnLoadMethod] private static void Reload() { diff --git a/Src/Core/Tween/BITween.cs b/Src/Core/Tween/BITween.cs index 686fa1e..268e70b 100644 --- a/Src/Core/Tween/BITween.cs +++ b/Src/Core/Tween/BITween.cs @@ -52,8 +52,7 @@ namespace BITKit.Tween t = math.clamp(t + delta*BITApp.Time.DeltaTime, 0, 1); var next = math.lerp(from, to, t); //BIT4Log.Log($"当前进度:[{t}]next:[{next}]"); - -#if UNITY_64 +#if UNITY_5_3_OR_NEWER await UniTask.NextFrame(cancellationToken); await UniTask.SwitchToMainThread(cancellationToken); #else diff --git a/Src/Unity/Scripts/Assets/BITFramework.cs b/Src/Unity/Scripts/Assets/BITFramework.cs index cafc5b8..456d57b 100644 --- a/Src/Unity/Scripts/Assets/BITFramework.cs +++ b/Src/Unity/Scripts/Assets/BITFramework.cs @@ -87,6 +87,7 @@ namespace BITKit BuildinQueryServices = buildinQueryServices, RemoteServices = remoteServices }; + #if UNITY_EDITOR if (IsEditorSimulateMode) { @@ -97,7 +98,9 @@ namespace BITKit EditorSimulateModeHelper.SimulateBuild("ScriptableBuildPipeline", packageName.Value) }; initParameters = editorParameters; - }else if (isOffline) + }else + #endif + if (isOffline) { initParameters = new OfflinePlayModeParameters(); } diff --git a/Src/Unity/Scripts/UX/ApplicationFile/UXApplicationFile.cs b/Src/Unity/Scripts/UX/ApplicationFile/UXApplicationFile.cs index b0dfbba..fd042d7 100644 --- a/Src/Unity/Scripts/UX/ApplicationFile/UXApplicationFile.cs +++ b/Src/Unity/Scripts/UX/ApplicationFile/UXApplicationFile.cs @@ -8,7 +8,7 @@ using UnityEngine.UIElements; namespace BITKit.UX { -#if !UNITY_WEBGL +#if UNITY_64 public class UXApplicationFile : MonoBehaviour { [SerializeReference, SubclassSelector] private IApplicationFile applicationFile; diff --git a/Src/Unity/Scripts/UX/ModService/UXModService.cs b/Src/Unity/Scripts/UX/ModService/UXModService.cs index e522e09..06a8f42 100644 --- a/Src/Unity/Scripts/UX/ModService/UXModService.cs +++ b/Src/Unity/Scripts/UX/ModService/UXModService.cs @@ -5,7 +5,9 @@ using System.Collections.Generic; using System.IO; using System.Reflection; using System.Threading; +#if UNITY_64 using AnotherFileBrowser.Windows; +#endif using BITKit.Mod; using Cysharp.Threading.Tasks; using UnityEngine; @@ -141,12 +143,16 @@ namespace BITKit.UX return; void OpenModInternal() { + #if UNITY_64 BIT4Log.Log("已进入文件对话框线程"); new FileBrowser().OpenFileBrowser(new BrowserProperties() { //filterIndex = 0, //filter = "C Sharp files (*.cs)|*.cs |Dll files (*.dll)|*.dll", }, Filepath); +#else + throw new NotSupportedException($"{Application.platform} 不支持打开文件对话框"); + #endif return; async void Filepath(string path) { @@ -159,9 +165,13 @@ namespace BITKit.UX switch (file.Extension) { case ".cs": + #if UNITY_64 var code = await File.ReadAllTextAsync(path); var assembly = BITSharp.Compile(code); await ModService.Load(assembly,Path.GetDirectoryName(path)); +#else + throw new NotSupportedException($"{Application.platform} 不支持编译C#代码"); + #endif break; case ".dll": var bytes = await File.ReadAllBytesAsync(path); diff --git a/Src/Unity/Scripts/Utility/Editor/BITInspector.cs b/Src/Unity/Scripts/Utility/Editor/BITInspector.cs index ffe2725..49b424c 100644 --- a/Src/Unity/Scripts/Utility/Editor/BITInspector.cs +++ b/Src/Unity/Scripts/Utility/Editor/BITInspector.cs @@ -22,6 +22,12 @@ namespace BITKit public class MonoBehaviorInspector : BITInspector { + } + [CanEditMultipleObjects] + [CustomEditor(typeof(ScriptableObject),true)] + public class ScriptableObjectInspector : BITInspector + { + } [CustomPropertyDrawer(typeof(ReadOnlyAttribute),true)] public class ReadOnlyDrawer : PropertyDrawer diff --git a/Src/Unity/Scripts/Utils/UnityApplicationFile.cs b/Src/Unity/Scripts/Utils/UnityApplicationFile.cs index 8a4f957..b6ff2da 100644 --- a/Src/Unity/Scripts/Utils/UnityApplicationFile.cs +++ b/Src/Unity/Scripts/Utils/UnityApplicationFile.cs @@ -3,14 +3,14 @@ using System.Collections.Generic; using UnityEditor; using UnityEngine; using UnityEngine.UIElements; - +#if UNITY_64 namespace BITKit.IO { public class UnityApplicationFile : MonoBehaviour { -#if !UNITY_WEBGL + [SerializeReference,SubclassSelector] internal IApplicationFile service; -#endif + } #if UNITY_EDITOR && !UNITY_WEBGL [CustomEditor(typeof(UnityApplicationFile))] @@ -49,4 +49,4 @@ namespace BITKit.IO } #endif } - +#endif diff --git a/Src/Unity/Scripts/WorldNode/WorldNodeService.cs b/Src/Unity/Scripts/WorldNode/WorldNodeService.cs index 73573de..f35159b 100644 --- a/Src/Unity/Scripts/WorldNode/WorldNodeService.cs +++ b/Src/Unity/Scripts/WorldNode/WorldNodeService.cs @@ -2,7 +2,6 @@ using System; using System.Collections; using System.Collections.Generic; using System.Linq; -using System.Windows.Forms; using Quadtree; using Quadtree.Items; using UnityEngine; diff --git a/Src/UnityEditor/SceneGizmoReference.cs b/Src/UnityEditor/SceneGizmoReference.cs index 8d02ee4..c78fb3c 100644 --- a/Src/UnityEditor/SceneGizmoReference.cs +++ b/Src/UnityEditor/SceneGizmoReference.cs @@ -10,7 +10,6 @@ namespace BITKit.Scene { [Export] public static bool AllowGizmos=true; - [SerializeField] private bool draw; [SerializeField] private Color color; [SerializeField] private float size;