revival/game/Assets/Scripts/Debug/CollisionGraphics.cs

45 lines
888 B
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExecuteAlways]
public class CollisionGraphics : MonoBehaviour
{
[SerializeField] private bool _showWhenEditing;
[SerializeField] private bool _showWhenPlaying;
private void OnEnable()
{
UpdateGraphics();
}
private void OnValidate()
{
UpdateGraphics();
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void UpdateGraphics()
{
foreach (var renderer in GetComponentsInChildren<Renderer>())
{
renderer.enabled = Application.isPlaying
? _showWhenPlaying
: _showWhenEditing;
}
}
}