using System.Collections; using System.Collections.Generic; using UnityEngine; public class TestAdd : MonoBehaviour { // Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Q)) { Debug.Log("Add"); Singleton.Instance.FaithCount+=1000; } if (Input.GetKeyDown(KeyCode.W)) { //Debug.Log("Add"); Singleton.Instance.WoodCount+=1000; } if (Input.GetMouseButtonDown(0)) // 检测鼠标左键点击 { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { GameObject clickedObject = hit.collider.gameObject; string objectName = clickedObject.name; string parentName = clickedObject.transform.parent != null ? clickedObject.transform.parent.name : "无父物体"; Debug.Log($"Clicked Object: {objectName}, Parent Object: {parentName}"); } } } }