更改文件架构
This commit is contained in:
58
Packages/Common~/Scripts/TranscodeProvider/DeUnicode.cs
Normal file
58
Packages/Common~/Scripts/TranscodeProvider/DeUnicode.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Text;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
namespace BITKit.Transfcodes
|
||||
{
|
||||
public sealed class DeUnicode : Transcode
|
||||
{
|
||||
public bool isMainThread;
|
||||
public new bool enabled;
|
||||
CancellationToken cancellationToken;
|
||||
void Start()
|
||||
{
|
||||
cancellationToken = gameObject.GetCancellationTokenOnDestroy();
|
||||
}
|
||||
public override async void Set(string t)
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
if (isMainThread)
|
||||
{
|
||||
await UniTask.SwitchToMainThread(cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
await UniTask.SwitchToTaskPool();
|
||||
}
|
||||
|
||||
output?.Set(FromUnicodeString(t));
|
||||
}
|
||||
else
|
||||
{
|
||||
output?.Set(t);
|
||||
}
|
||||
|
||||
}
|
||||
public static string FromUnicodeString(string str)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new Regex(@"\\u([0-9A-F]{4})", RegexOptions.IgnoreCase | RegexOptions.Compiled).Replace(
|
||||
str, x => string.Empty + Convert.ToChar(Convert.ToUInt16(x.Result("$1"), 16)));
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogWarning(str);
|
||||
Debug.LogException(e);
|
||||
return str;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/TranscodeProvider/DeUnicode.cs.meta
Normal file
11
Packages/Common~/Scripts/TranscodeProvider/DeUnicode.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0d8326bf2504a5a4fa93c8b586c59a8c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
22
Packages/Common~/Scripts/TranscodeProvider/Transcode.cs
Normal file
22
Packages/Common~/Scripts/TranscodeProvider/Transcode.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Text;
|
||||
namespace BITKit.Transfcodes
|
||||
{
|
||||
public abstract class Transcode : Provider<string>
|
||||
{
|
||||
public Provider output;
|
||||
public override string Get()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
public override void Set(string t)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
11
Packages/Common~/Scripts/TranscodeProvider/Transcode.cs.meta
Normal file
11
Packages/Common~/Scripts/TranscodeProvider/Transcode.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 970cb5f1fd10cbe48ba9d61564fa71e0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "TranscodeProvider",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:a209c53514018594f9f482516f2a6781",
|
||||
"GUID:f51ebe6a0ceec4240a699833d6309b23",
|
||||
"GUID:be17a8778dbfe454890ed8279279e153",
|
||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||
"GUID:9400d40641bab5b4a9702f65bf5c6eb5"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 178bc7f5ff94d134fb0c18f82f80fae9
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user