breakpoint
before update unity version
This commit is contained in:
67
Assets/BITKit/Unity/Scripts/Win64/UnitySubApp.cs
Normal file
67
Assets/BITKit/Unity/Scripts/Win64/UnitySubApp.cs
Normal 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.UTF8,
|
||||
StandardInputEncoding = System.Text.Encoding.UTF8,
|
||||
StandardOutputEncoding = System.Text.Encoding.UTF8,
|
||||
};
|
||||
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();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user