浏览代码

New feature: The errors happening in Unity will be reported in the unity-environment.log file that will be generated when an environment with an external Brain is launched.

This should help developers figure out faster if errors are happening on the Unity side.
Looking into the Player.Log or using a developement build could be replaced by this feature.
/tag-0.2.0
vincentpierre 7 年前
当前提交
4c8efaeb
共有 2 个文件被更改,包括 22 次插入0 次删除
  1. 3
      .gitignore
  2. 19
      unity-environment/Assets/ML-Agents/Scripts/ExternalCommunicator.cs

3
.gitignore


/python/models
/python/summaries
# Environemnt logfile
/python/unity-environment.log
# Visual Studio 2015 cache directory
/unity-environment/.vs/

19
unity-environment/Assets/ML-Agents/Scripts/ExternalCommunicator.cs


using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.IO;
/// Responsible for communication with Python API.

byte[] messageHolder;
const int messageLength = 12000;
StreamWriter logWriter;
string logPath;
const string api = "API-2";

/// Contains the logic for the initializtation of the socket.
public void InitializeCommunicator()
{
Application.logMessageReceived += HandleLog;
logPath = Path.GetFullPath(".") + "/unity-environment.log";
logWriter = new StreamWriter(logPath, false);
logWriter.WriteLine(System.DateTime.Now.ToString());
logWriter.WriteLine(" ");
logWriter.Close();
messageHolder = new byte[messageLength];
// Create a TCP/IP socket.

SendParameters(accParamerters);
}
void HandleLog(string logString, string stackTrace, LogType type)
{
logWriter = new StreamWriter(logPath, true);
logWriter.WriteLine(type.ToString());
logWriter.WriteLine(logString);
logWriter.WriteLine(stackTrace);
logWriter.Close();
}
/// Listens to the socket for a command and returns the corresponding
/// External Command.

正在加载...
取消
保存