add side channel to let python side know which target got win or lose. fix update time bug. may cause double gameover check.(got another lose after reset the game.)
42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using Unity.MLAgents;
|
|
using Unity.MLAgents.SideChannels;
|
|
using System;
|
|
|
|
public class AimbotSideChannel : SideChannel
|
|
{
|
|
public AimbotSideChannel()
|
|
{
|
|
ChannelId = new Guid("8bbfb62a-99b4-457c-879d-b78b69066b5e");
|
|
}
|
|
protected override void OnMessageReceived(IncomingMessage msg)
|
|
{
|
|
var receivedString = msg.ReadString();
|
|
Debug.Log("From Python : " + receivedString);
|
|
}
|
|
|
|
public void SendDebugStatementToPython(string logString, string stackTrace, LogType type)
|
|
{
|
|
if (type == LogType.Warning)
|
|
{
|
|
var stringToSend = "result|"+logString;
|
|
using (var msgOut = new OutgoingMessage())
|
|
{
|
|
msgOut.WriteString(stringToSend);
|
|
QueueMessageToSend(msgOut);
|
|
}
|
|
}
|
|
if (type == LogType.Error)
|
|
{
|
|
var stringToSend = "Error|"+logString;
|
|
using (var msgOut = new OutgoingMessage())
|
|
{
|
|
msgOut.WriteString(stringToSend);
|
|
QueueMessageToSend(msgOut);
|
|
}
|
|
}
|
|
}
|
|
}
|