Files
2026-03-04 10:03:45 +08:00

48 lines
1.1 KiB
C#

using UnityEngine;
using UnityEngine.UI;
public class DCords : MonoBehaviour
{
[SerializeField]
private Text cordsText;
[SerializeField]
public GameObject markerPrefab;
public static string cordsString;
[HideInInspector]
public Vector3 pos;
private FPlayer fPlayer;
private void Start()
{
FPlayer[] array = Object.FindObjectsOfType<FPlayer>();
for (int i = 0; i < array.Length; i++)
{
if (array[i].gameObject.activeSelf)
{
fPlayer = array[i];
}
}
}
public void ShowMarker()
{
Object.Instantiate(markerPrefab).transform.position = new Vector3(pos.x, pos.y, pos.z);
}
private void Update()
{
if (fPlayer != null)
{
cordsText.text = "X: " + fPlayer.gameObject.transform.position.x.ToString("F0") + " Y:" + fPlayer.gameObject.transform.position.y.ToString("F0") + " Z: " + fPlayer.gameObject.transform.position.z.ToString("F0") + " F9 - copy to clipboard";
}
if (Input.GetKeyDown(KeyCode.F9))
{
GUIUtility.systemCopyBuffer = fPlayer.gameObject.transform.position.x.ToString("F0") + "," + fPlayer.gameObject.transform.position.y.ToString("F0") + "," + fPlayer.gameObject.transform.position.z.ToString("F0");
}
}
}