Files
ui/Assets/ObjectSelector.cs
2026-01-07 23:54:53 -05:00

26 lines
691 B
C#

using UnityEngine;
public class ObjectSelector : MonoBehaviour
{
public static GameObject selectedObject;
void Update()
{
Debug.Log("Selector is running");
if (Input.GetMouseButtonDown(0))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out RaycastHit hit))
{
Debug.Log("Hit: " + hit.collider.gameObject.name);
if (hit.collider.CompareTag("Selectable"))
{
ObjectSelector.selectedObject = hit.collider.transform.root.gameObject;
Debug.Log("Selected Root Object: " + ObjectSelector.selectedObject.name);
}
}
}
}
}