This commit is contained in:
CortexCore 2024-06-14 14:12:02 +08:00
parent 349877fe7a
commit ca93bd2c56
9 changed files with 24 additions and 24 deletions

View File

@ -1,6 +1,6 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
#if UNITY_64 #if UNITY_5_3_OR_NEWER
using UnityEngine; using UnityEngine;
#endif #endif
@ -25,7 +25,7 @@ namespace BITKit
public static event Action<ConsoleColor> OnSetConsoleColor; public static event Action<ConsoleColor> OnSetConsoleColor;
public static event Action OnNextLine; public static event Action OnNextLine;
private static Type currentType; private static Type currentType;
#if UNITY_64 #if UNITY_5_3_OR_NEWER
//[HideInCallstack] //[HideInCallstack]
#endif #endif
public static void Log(object x, ConsoleColor color = ConsoleColor.White) public static void Log(object x, ConsoleColor color = ConsoleColor.White)
@ -33,7 +33,7 @@ namespace BITKit
OnSetConsoleColor?.Invoke(color); OnSetConsoleColor?.Invoke(color);
OnLog?.Invoke(x?.ToString()); OnLog?.Invoke(x?.ToString());
} }
#if UNITY_64 #if UNITY_5_3_OR_NEWER
[HideInCallstack] [HideInCallstack]
#endif #endif
public static void Log<T>(object x, ConsoleColor color = ConsoleColor.White) public static void Log<T>(object x, ConsoleColor color = ConsoleColor.White)
@ -50,21 +50,21 @@ namespace BITKit
currentType = typeof(T); currentType = typeof(T);
} }
#if UNITY_64 #if UNITY_5_3_OR_NEWER
[HideInCallstack] [HideInCallstack]
#endif #endif
public static void LogException(Exception e) public static void LogException(Exception e)
{ {
OnException?.Invoke(e); OnException?.Invoke(e);
} }
#if UNITY_64 #if UNITY_5_3_OR_NEWER
[HideInCallstack] [HideInCallstack]
#endif #endif
public static void Warning(object x) public static void Warning(object x)
{ {
OnWarning?.Invoke(x.ToString()); OnWarning?.Invoke(x.ToString());
} }
#if UNITY_64 #if UNITY_5_3_OR_NEWER
[HideInCallstack] [HideInCallstack]
#endif #endif
public static void Warning<T>(object x) public static void Warning<T>(object x)

View File

@ -4,12 +4,12 @@ using System.Linq;
using System.Reflection; using System.Reflection;
using Cysharp.Threading.Tasks; using Cysharp.Threading.Tasks;
using System.Text; using System.Text;
#if UNITY_64 #if UNITY_5_3_OR_NEWER
using UnityEngine; using UnityEngine;
#endif #endif
namespace BITKit namespace BITKit
{ {
#if UNITY_64 #if UNITY_5_3_OR_NEWER
[Serializable] [Serializable]
public sealed class ExecuteCommandAction : IAction public sealed class ExecuteCommandAction : IAction
{ {

View File

@ -253,7 +253,7 @@ namespace BITKit.Mod
await Load(assembly); await Load(assembly);
continue; continue;
} }
#if UNITY_64 #if UNITY_5_3_OR_NEWER
case ".cs": case ".cs":
{ {
var code = await File.ReadAllTextAsync(fileInfo.FullName); var code = await File.ReadAllTextAsync(fileInfo.FullName);
@ -352,7 +352,7 @@ namespace BITKit.Mod
//Thread.Sleep(1000); //Thread.Sleep(1000);
#if UNITY_64 #if UNITY_5_3_OR_NEWER
await UniTask.Delay(1000); await UniTask.Delay(1000);
#else #else
await Task.Delay(1000); await Task.Delay(1000);
@ -465,7 +465,7 @@ namespace BITKit.Mod
await Load(assembly, fileInfo.DirectoryName); await Load(assembly, fileInfo.DirectoryName);
break; break;
} }
#if UNITY_64 #if UNITY_5_3_OR_NEWER
case ".cs": case ".cs":
{ {
var code = await File.ReadAllTextAsync(fileInfo.FullName); var code = await File.ReadAllTextAsync(fileInfo.FullName);

View File

@ -17,7 +17,7 @@ namespace BITKit
} }
public interface ISelectable public interface ISelectable
{ {
#if UNITY_64 #if UNITY_5_3_OR_NEWER
UnityEngine.Transform Transform { get; } UnityEngine.Transform Transform { get; }
#endif #endif
void SetSelectionState(SelectionState state); void SetSelectionState(SelectionState state);

View File

@ -11,7 +11,7 @@ using System.Text;
using System.Threading; using System.Threading;
using BITKit.Mod; using BITKit.Mod;
#if UNITY_64 #if UNITY_5_3_OR_NEWER
using System.Collections; using System.Collections;
using BITKit.UX; using BITKit.UX;
using UnityEngine; using UnityEngine;
@ -26,7 +26,7 @@ namespace BITKit
{ {
public class BITSharp public class BITSharp
{ {
#if UNITY_64 #if UNITY_5_3_OR_NEWER
[RuntimeInitializeOnLoadMethod] [RuntimeInitializeOnLoadMethod]
private static void Reload() private static void Reload()
{ {
@ -60,7 +60,7 @@ namespace BITKit
assemblies ??= AppDomain.CurrentDomain.GetAssemblies(); assemblies ??= AppDomain.CurrentDomain.GetAssemblies();
return assemblies.Select(assembly => assembly.GetType(fullName, false)).FirstOrDefault(type => type is not null); return assemblies.Select(assembly => assembly.GetType(fullName, false)).FirstOrDefault(type => type is not null);
} }
#if UNITY_64 #if UNITY_5_3_OR_NEWER
public static Assembly Compile(params string[] codes) public static Assembly Compile(params string[] codes)
{ {

View File

@ -1,4 +1,4 @@
#if UNITY_64 #if UNITY_5_3_OR_NEWER
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Concurrent; using System.Collections.Concurrent;
@ -34,7 +34,7 @@ namespace BITKit.IO
{ {
private const string DefaultPath = nameof(ApplicationFile)+"."+nameof(DefaultPath); private const string DefaultPath = nameof(ApplicationFile)+"."+nameof(DefaultPath);
#if UNITY_64 #if UNITY_5_3_OR_NEWER
[UnityEngine.RuntimeInitializeOnLoadMethod] [UnityEngine.RuntimeInitializeOnLoadMethod]
private static void Reload() private static void Reload()
{ {
@ -66,7 +66,7 @@ namespace BITKit.IO
get get
{ {
var bp = new BrowserProperties(); var bp = new BrowserProperties();
#if UNITY_64 #if UNITY_5_3_OR_NEWER
if (PlayerPrefs.HasKey(DefaultPath)) if (PlayerPrefs.HasKey(DefaultPath))
{ {
bp.initialDir = PlayerPrefs.GetString(DefaultPath); bp.initialDir = PlayerPrefs.GetString(DefaultPath);

View File

@ -1,5 +1,5 @@
using System; using System;
#if UNITY_64 #if UNITY_5_3_OR_NEWER
using UnityEngine; using UnityEngine;
#endif #endif
namespace BITKit namespace BITKit
@ -8,7 +8,7 @@ namespace BITKit
{ {
public ConstantHash(object value) public ConstantHash(object value)
{ {
#if UNITY_64 #if UNITY_5_3_OR_NEWER
HashCode = Animator.StringToHash(value.ToString()); HashCode = Animator.StringToHash(value.ToString());
#else #else
HashCode = value.GetHashCode(); HashCode = value.GetHashCode();

View File

@ -8,7 +8,7 @@ using UnityEngine.UIElements;
namespace BITKit.UX namespace BITKit.UX
{ {
#if UNITY_64 #if UNITY_5_3_OR_NEWER
public class UXApplicationFile : MonoBehaviour public class UXApplicationFile : MonoBehaviour
{ {
[SerializeReference, SubclassSelector] private IApplicationFile applicationFile; [SerializeReference, SubclassSelector] private IApplicationFile applicationFile;

View File

@ -5,7 +5,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Threading; using System.Threading;
#if UNITY_64 #if UNITY_5_3_OR_NEWER
using AnotherFileBrowser.Windows; using AnotherFileBrowser.Windows;
#endif #endif
using BITKit.Mod; using BITKit.Mod;
@ -143,7 +143,7 @@ namespace BITKit.UX
return; return;
void OpenModInternal() void OpenModInternal()
{ {
#if UNITY_64 #if UNITY_5_3_OR_NEWER
BIT4Log.Log<UXModService>("已进入文件对话框线程"); BIT4Log.Log<UXModService>("已进入文件对话框线程");
new FileBrowser().OpenFileBrowser(new BrowserProperties() new FileBrowser().OpenFileBrowser(new BrowserProperties()
{ {
@ -165,7 +165,7 @@ namespace BITKit.UX
switch (file.Extension) switch (file.Extension)
{ {
case ".cs": case ".cs":
#if UNITY_64 #if UNITY_5_3_OR_NEWER
var code = await File.ReadAllTextAsync(path); var code = await File.ReadAllTextAsync(path);
var assembly = BITSharp.Compile(code); var assembly = BITSharp.Compile(code);
await ModService.Load(assembly,Path.GetDirectoryName(path)); await ModService.Load(assembly,Path.GetDirectoryName(path));