You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.1 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DebugUI : MonoBehaviour
{
public bool debugMode = true;
public GameObject debugUI;
Ray ray;
public RaycastHit hit = new RaycastHit();
// Start is called before the first frame update
void Start()
{
debugUI.SetActive(debugMode);
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.A))
{
debugMode = !debugMode;
debugUI.SetActive(debugMode);
}
if (debugMode && Input.GetMouseButtonDown(0))
{
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
GameObject selected_obj = null;
if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 200.0f))
{
selected_obj = hit.collider.gameObject;
Debug.Log("hit!!" + selected_obj.name);
}
if(selected_obj != null)
{
selected_obj.GetComponent<Renderer>().material.color = new Color(255, 100, 100);
}
}
}
}