This commit is contained in:
CortexCore 2025-01-23 11:39:53 +08:00
parent 000a079985
commit 57e24939fb
7 changed files with 52 additions and 18 deletions

View File

@ -38,7 +38,7 @@
<ItemGroup>
<PackageReference Include="Kcp" Version="2.6.3" />
<PackageReference Include="MemoryPack.Core" Version="1.21.1" />
<PackageReference Include="MemoryPack" Version="1.21.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.9" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />

View File

@ -9,6 +9,7 @@ using System.IO;
using System.Linq;
using System.Text;
using Cysharp.Threading.Tasks;
using MemoryPack;
using Microsoft.SqlServer.Server;
#if NET5_0_OR_GREATER
using Microsoft.SqlServer.Server;
@ -107,22 +108,27 @@ namespace BITKit
return instance;
}
var json = reader.ReadString();
if (string.IsNullOrEmpty(json))
if (BITSharp.TryGetTypeFromFullName(typeName, out type))
{
throw new Exception($"从二进制中读取的json值为空");
return MemoryPackSerializer.Deserialize(type, reader.ReadBytes(reader.ReadInt32()));
}
try
{
if (BITSharp.TryGetTypeFromFullName(typeName, out type))
return JsonConvert.DeserializeObject(json, type);
}
catch (Exception e)
{
BIT4Log.Warning<BITBinary>($"反序列化失败,类型:{typeName},值:\n{json}");
BIT4Log.LogException(e);
}
// var json = reader.ReadString();
// if (string.IsNullOrEmpty(json))
// {
// throw new Exception($"从二进制中读取的json值为空");
// }
//
// try
// {
// if (BITSharp.TryGetTypeFromFullName(typeName, out type))
// return JsonConvert.DeserializeObject(json, type);
// }
// catch (Exception e)
// {
// BIT4Log.Warning<BITBinary>($"反序列化失败,类型:{typeName},值:\n{json}");
// BIT4Log.LogException(e);
// }
throw new Exception("未找到读取该二进制的BinaryReader");
}
@ -172,7 +178,11 @@ namespace BITKit
{
try
{
writer.Write(JsonConvert.SerializeObject(value));
var bytes = MemoryPackSerializer.Serialize(value.GetType(),value);
writer.Write(bytes.Length);
writer.Write(bytes);
//writer.Write(JsonConvert.SerializeObject(value));
}
catch (Exception)
{

View File

@ -17,7 +17,6 @@ using BITKit.Net.Examples;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Unity.Mathematics;
using UnityEngine;
namespace BITKit.Net
{

View File

@ -1,6 +1,9 @@
using MemoryPack;
namespace BITKit.Net.Examples
{
public struct NetClientAllocateIdCommand
[MemoryPackable]
public partial struct NetClientAllocateIdCommand
{
public int Id;
public string Ip;

View File

@ -64,8 +64,11 @@ namespace BITKit.StateMachine
if(_cancellationTokenSource.IsCancellationRequested)return;
if (CurrentState is null) return;
using var _ = IsBusy.GetHandle();
if (CurrentState is not null)
{
CurrentState.Enabled = false;
}
await CurrentState.OnStateExitAsync(CurrentState, null);
if(_cancellationTokenSource.IsCancellationRequested)return;
CurrentState.OnStateExit(CurrentState, null);
CurrentState = null;
}

View File

@ -6,6 +6,7 @@ using System.IO;
using BITKit.IO;
using BITKit.UX;
using Cysharp.Threading.Tasks;
using UnityEditorInternal;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Rendering;

View File

@ -508,3 +508,21 @@ Button.clear {
TabContainer > * {
flex-grow: 1;
}
.transition_entry {
opacity: 0;
}
.transition_entry_async {
opacity: 1;
transition-duration: 0.1s;
}
.transition_exit {
opacity: 1;
}
.transition_exit_async {
opacity: 0;
transition-duration: 0.1s;
}