This commit is contained in:
CortexCore
2024-03-31 23:31:00 +08:00
parent e179d2eb53
commit b7b89ee71a
641 changed files with 31286 additions and 22134 deletions

View File

@@ -6,7 +6,9 @@
"GUID:f51ebe6a0ceec4240a699833d6309b23",
"GUID:be17a8778dbfe454890ed8279279e153",
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
"GUID:9400d40641bab5b4a9702f65bf5c6eb5"
"GUID:9400d40641bab5b4a9702f65bf5c6eb5",
"GUID:d525ad6bd40672747bde77962f1c401e",
"GUID:49b49c76ee64f6b41bf28ef951cb0e50"
],
"includePlatforms": [],
"excludePlatforms": [],

View File

@@ -11,9 +11,9 @@ namespace BITKit
public class RegistryRunAPP : MonoBehaviour
{
[Header(Constant.Header.Settings)]
public string subKey;
public string excutablePath;
public bool excuteOnStart;
[SerializeReference,SubclassSelector] private IReference subKey;
[SerializeReference,SubclassSelector] private string executablePath;
private bool executeOnStart;
[Header(Constant.Header.Events)]
public UnityEvent<bool> onSuccess = new();
public UnityEvent onfailure = new();
@@ -23,7 +23,7 @@ namespace BITKit
{
Debug.Log("正在启动注册函数");
var path = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
var result = RegisterAppKey(subKey, path);
var result = RegisterAppKey(subKey.Value, path);
Debug.Log($"正在注册启动:{subKey}:{path}");
if (result)
{
@@ -46,7 +46,7 @@ namespace BITKit
async void Start()
{
await UniTask.Yield();
if (excuteOnStart) Excute();
if (executeOnStart) Excute();
}
private static bool RegisterAppKey(string keyName, string value)
{

View File

@@ -0,0 +1,67 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using UnityEngine;
namespace BITKit
{
public class UnitySubApp : MonoBehaviour,IAction
{
[SerializeReference,SubclassSelector] private IReference path;
[SerializeReference,SubclassSelector] private IReference arguments;
[SerializeField] private bool isStreamingAssets;
private void Start()
{
Execute();
}
public void Execute()
{
var StartInfo = new ProcessStartInfo
{
FileName =isStreamingAssets ? Path.Combine(Application.streamingAssetsPath, path.Value) : path.Value,
WorkingDirectory =Environment.CurrentDirectory,
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardOutput = true,
RedirectStandardError =true,
StandardErrorEncoding = System.Text.Encoding.GetEncoding("gb2312"),
//StandardInputEncoding = System.Text.Encoding.GetEncoding("gb2312"),
StandardOutputEncoding = System.Text.Encoding.GetEncoding("gb2312"),
};
if(arguments != null)
{
StartInfo.Arguments = arguments.Value;
}
var process = new Process()
{
StartInfo = StartInfo,
};
process.OutputDataReceived += (sender, args) =>
{
BIT4Log.Log<UnitySubApp>(args.Data);
};
process.ErrorDataReceived += (sender, args) =>
{
BIT4Log.Warning<UnitySubApp>(args.Data);
};
BIT4Log.Log<UnitySubApp>($"已创建进程:{StartInfo.FileName}");
process.Start();
process.BeginErrorReadLine();
process.BeginOutputReadLine();
destroyCancellationToken.Register(()=>
{
if(process.HasExited is false)
process.Kill();
});
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ddd3add402b85d442a6401327d8ad500
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: