MayHeCome/Assets/Scripts/TestAdd.cs
2024-12-18 17:55:34 +08:00

37 lines
1.1 KiB
C#

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<GameProcedureManager>.Instance.FaithCount+=1000;
}
if (Input.GetKeyDown(KeyCode.W))
{
//Debug.Log("Add");
Singleton<GameProcedureManager>.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}");
}
}
}
}