File size: 1,132 Bytes
7b5e094 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class WeightDisplay : MonoBehaviour
{
private Agent agentRef;
public Text title;
public List<Text> weightList = new List<Text>(5);
void Update()
{
//if (Input.GetMouseButtonDown(0))
//{
// RaycastHit hit;
// Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
// if (Physics.Raycast(ray, out hit, 50.0f)) {
// selectedCube = hit.transform.gameObject;
// }
//}
//DisplaySelectedCube(selectedCube);
}
public void DisplaySelectedCube(GameObject selectedCube)
{
if (selectedCube != null)
{
(int, int) position = selectedCube.GetComponent<FloorCube>().position;
title.text = $"X: {position.Item1} Y: {position.Item2}";
agentRef = FindObjectOfType<Agent>();
for (int i = 0; i < weightList.Capacity; ++i)
{
weightList[i].text = agentRef.StateActionPairQValue[(position, (Action)i)].ToString();
}
}
}
}
|