Files
NeuralNetworks.Unity/Assets/Agent.cs
T

39 lines
1009 B
C#
Raw Normal View History

2025-05-13 02:53:08 +03:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Agent : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
public Vector2 ImageSpacePosition {
get {
var thisTransform = GetComponent<RectTransform>();
return new Vector3(thisTransform.anchoredPosition.x, -thisTransform.anchoredPosition.y);
}
}
public Vector2 ImageSpacePositionNormalized {
get {
var localPos = ImageSpacePosition;
var parentTransform = transform.parent.GetComponent<RectTransform>();
var parentSize = parentTransform.rect.size;
return new Vector2(localPos.x / parentSize.x, localPos.y / parentSize.y);
}
}
// Update is called once per frame
void Update()
{
if (transform.hasChanged) {
Debug.Log(ImageSpacePositionNormalized);
transform.hasChanged = false;
}
}
}