V3.4 追加Save Model按钮
追加Save Model按钮,对应按钮按下时显示message修改了font
This commit is contained in:
+6
-1
@@ -2,7 +2,7 @@ using Unity.MLAgents;
|
||||
using Unity.MLAgents.SideChannels;
|
||||
using UnityEngine;
|
||||
|
||||
public class AimBotSideChennelController : MonoBehaviour
|
||||
public class AimBotSideChannelController : MonoBehaviour
|
||||
{
|
||||
public AimbotSideChannel aimbotSideChannel;
|
||||
|
||||
@@ -28,4 +28,9 @@ public class AimBotSideChennelController : MonoBehaviour
|
||||
SideChannelManager.UnregisterSideChannel(aimbotSideChannel);
|
||||
}
|
||||
}
|
||||
|
||||
public void SendSideChannelMessage(string MessageType, string message)
|
||||
{
|
||||
Debug.LogWarning(MessageType + "|" + message);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ea781484763623c438c1806e3a965667
|
||||
guid: 9585e6d628809d14ba93cb74005c3514
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -206,7 +206,7 @@ public class AgentController : MonoBehaviour
|
||||
lastShootTime = Time.time;
|
||||
if (Physics.Raycast(ray, out hit, 100))
|
||||
{
|
||||
if (hit.collider.tag != myTag && hit.collider.tag != "Wall")
|
||||
if (hit.collider.tag != myTag && hit.collider.tag != "Wall" && hit.collider.tag != "Untagged")
|
||||
{
|
||||
// kill enemy
|
||||
GameObject gotHitObj = hit.transform.gameObject;//获取受到Ray撞击的对象
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -6,13 +7,24 @@ using UnityEngine.UI;
|
||||
public class HUDController : MonoBehaviour
|
||||
{
|
||||
public bool chartOn = false;
|
||||
public GameObject sideChannelObj;
|
||||
public Toggle chartOnToggleObj;
|
||||
public Button saveModelButton;
|
||||
public TMP_InputField chartOnTimeOutInputObj;
|
||||
public TMP_InputField enemyNumInputObj;
|
||||
public float chartOnTimeOut = 1;
|
||||
public int enemyNum = 3;
|
||||
public float chartOnTimeOutDefault = 120f;
|
||||
|
||||
private float chatOntimeStart = 0;
|
||||
private AimBotSideChannelController sideChannelController;
|
||||
private MessageBoxController messageBox;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
sideChannelController = sideChannelObj.GetComponent<AimBotSideChannelController>();
|
||||
messageBox = gameObject.GetComponent<MessageBoxController>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
@@ -55,4 +67,11 @@ public class HUDController : MonoBehaviour
|
||||
chartOnTimeOut = chartOnTimeOutDefault;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnSaveModelButtonPressed()
|
||||
{
|
||||
// Send message to python to save model
|
||||
sideChannelController.SendSideChannelMessage("Command", "SaveModel");
|
||||
messageBox.PushMessage(new List<string> { "☑Model Will be Saved In Next Train Episode:)" }, new List<string> { messageBox.goodColor });
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ public class MLAgentsCustomController : Agent
|
||||
public GameObject paramContainerObj;
|
||||
public GameObject targetControllerObj;
|
||||
public GameObject environmentUIObj;
|
||||
public GameObject sideChannelObj;
|
||||
public GameObject hudUIObj;
|
||||
|
||||
[Header("Env")]
|
||||
@@ -25,6 +26,7 @@ public class MLAgentsCustomController : Agent
|
||||
private TargetUIController targetUIController;
|
||||
private RaySensors raySensors;
|
||||
private MessageBoxController messageBoxController;
|
||||
private AimBotSideChannelController sideChannelController;
|
||||
|
||||
// observation
|
||||
private float[] myObserve = new float[4];
|
||||
@@ -50,6 +52,7 @@ public class MLAgentsCustomController : Agent
|
||||
hudController = hudUIObj.GetComponent<HUDController>();
|
||||
targetUIController = hudUIObj.GetComponent<TargetUIController>();
|
||||
messageBoxController = hudUIObj.GetComponent<MessageBoxController>();
|
||||
sideChannelController = sideChannelObj.GetComponent<AimBotSideChannelController>();
|
||||
}
|
||||
|
||||
#region On episode begin function
|
||||
@@ -175,14 +178,14 @@ public class MLAgentsCustomController : Agent
|
||||
switch (finishedState)
|
||||
{
|
||||
case (int)TargetController.EndType.Win:
|
||||
Debug.LogWarning("Result|" + targetString + "|Win");
|
||||
sideChannelController.SendSideChannelMessage("Result",targetString+ "|Win");
|
||||
messageBoxController.PushMessage(
|
||||
new List<string> { "Game Win" },
|
||||
new List<string> { "green" });
|
||||
break;
|
||||
|
||||
case (int)TargetController.EndType.Lose:
|
||||
Debug.LogWarning("Result|" + targetString + "|Lose");
|
||||
sideChannelController.SendSideChannelMessage("Result", targetString + "|Lose");
|
||||
messageBoxController.PushMessage(
|
||||
new List<string> { "Game Lose" },
|
||||
new List<string> { "red" });
|
||||
|
||||
@@ -8,6 +8,7 @@ public class MessageBoxController : MonoBehaviour
|
||||
public string defaultColor = "white";
|
||||
public string warningColor = "#ffa500ff";
|
||||
public string errorColor = "#800000ff";
|
||||
public string goodColor = "#00ff00ff";
|
||||
public GameObject messagePanelObj;
|
||||
public GameObject messageTextPrefab;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user