오브젝트 선택창
This commit is contained in:
@@ -1,8 +1,17 @@
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class SimulationModel : MonoBehaviour
|
||||
public class SimulationModel : MonoBehaviour, IClickable
|
||||
{
|
||||
public string modelName;
|
||||
public string modelType;
|
||||
public string modelID;
|
||||
private bool isQuitting = false;
|
||||
void Awake()
|
||||
{
|
||||
FitCollider();
|
||||
}
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
@@ -27,5 +36,25 @@ public class SimulationModel : MonoBehaviour
|
||||
void OnApplicationQuit()
|
||||
{
|
||||
isQuitting = true;
|
||||
}
|
||||
}
|
||||
public void OnClick()
|
||||
{
|
||||
Debug.Log("Clicked : " + gameObject.name);
|
||||
}
|
||||
void FitCollider()
|
||||
{
|
||||
var renderers = GetComponentsInChildren<Renderer>();
|
||||
if (renderers.Length == 0) return;
|
||||
|
||||
Bounds bounds = renderers[0].bounds;
|
||||
foreach (var r in renderers)
|
||||
bounds.Encapsulate(r.bounds);
|
||||
|
||||
BoxCollider collider = GetComponent<BoxCollider>();
|
||||
if (!collider) collider = gameObject.AddComponent<BoxCollider>();
|
||||
|
||||
collider.center = transform.InverseTransformPoint(bounds.center);
|
||||
collider.size = transform.InverseTransformVector(bounds.size);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user