115 lines
3.9 KiB
C#
115 lines
3.9 KiB
C#
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
namespace GameSystems.Optimization
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
/// PlayerRangeManager의 설정을 관리하는 ScriptableObject
|
||
|
|
/// - 프로젝트 전역 설정 공유
|
||
|
|
/// - 런타임 수정 불가 (데이터 무결성 보장)
|
||
|
|
/// </summary>
|
||
|
|
[CreateAssetMenu(fileName = "RenderOptimizationConfig", menuName = "Game Systems/Render Optimization Config")]
|
||
|
|
public sealed class RenderOptimizationConfig : ScriptableObject
|
||
|
|
{
|
||
|
|
#region Inspector Fields
|
||
|
|
|
||
|
|
[Header("=== 렌더링 범위 설정 ===")]
|
||
|
|
[Tooltip("플레이어 주변 렌더링 반지름 (유니티 단위)")]
|
||
|
|
[SerializeField, Range(10f, 200f)]
|
||
|
|
private float _renderRange = 40f;
|
||
|
|
|
||
|
|
[Tooltip("페이드 아웃 시작 거리 비율 (0.8 = 렌더 범위의 80%부터 페이드 시작)")]
|
||
|
|
[SerializeField, Range(0.5f, 1f)]
|
||
|
|
private float _fadeStartRatio = 0.8f;
|
||
|
|
|
||
|
|
[Header("=== 업데이트 주기 ===")]
|
||
|
|
[Tooltip("오브젝트 컬링 검사 주기 (초 단위)")]
|
||
|
|
[SerializeField, Range(0.05f, 1f)]
|
||
|
|
private float _checkInterval = 0.2f;
|
||
|
|
|
||
|
|
[Header("=== 플레이어 설정 ===")]
|
||
|
|
[Tooltip("플레이어를 찾을 태그 이름")]
|
||
|
|
[SerializeField]
|
||
|
|
private string _playerTag = "Player";
|
||
|
|
|
||
|
|
[Header("=== 성능 설정 ===")]
|
||
|
|
[Tooltip("한 프레임에 처리할 최대 오브젝트 수 (0 = 무제한)")]
|
||
|
|
[SerializeField, Range(0, 500)]
|
||
|
|
private int _maxObjectsPerFrame = 0;
|
||
|
|
|
||
|
|
[Tooltip("비활성 오브젝트도 스캔할지 여부")]
|
||
|
|
[SerializeField]
|
||
|
|
private bool _includeInactiveObjects = true;
|
||
|
|
|
||
|
|
[Header("=== 디버그 설정 ===")]
|
||
|
|
[Tooltip("기즈모 표시 여부")]
|
||
|
|
[SerializeField]
|
||
|
|
private bool _showGizmos = true;
|
||
|
|
|
||
|
|
[Tooltip("상세 로그 출력")]
|
||
|
|
[SerializeField]
|
||
|
|
private bool _enableVerboseLogging = false;
|
||
|
|
|
||
|
|
#endregion
|
||
|
|
|
||
|
|
#region Public Properties (Immutable)
|
||
|
|
|
||
|
|
public float RenderRange => _renderRange;
|
||
|
|
public float FadeStartRatio => _fadeStartRatio;
|
||
|
|
public float CheckInterval => _checkInterval;
|
||
|
|
public string PlayerTag => _playerTag;
|
||
|
|
public int MaxObjectsPerFrame => _maxObjectsPerFrame;
|
||
|
|
public bool IncludeInactiveObjects => _includeInactiveObjects;
|
||
|
|
public bool ShowGizmos => _showGizmos;
|
||
|
|
public bool EnableVerboseLogging => _enableVerboseLogging;
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 페이드 시작 거리 계산
|
||
|
|
/// </summary>
|
||
|
|
public float FadeStartDistance => _renderRange * _fadeStartRatio;
|
||
|
|
|
||
|
|
#endregion
|
||
|
|
|
||
|
|
#region Validation
|
||
|
|
|
||
|
|
private void OnValidate()
|
||
|
|
{
|
||
|
|
// 유효성 검사
|
||
|
|
if (_renderRange < 10f)
|
||
|
|
{
|
||
|
|
Debug.LogWarning("[RenderOptimizationConfig] Render Range가 너무 작습니다. 최소 10으로 설정됩니다.");
|
||
|
|
_renderRange = 10f;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (string.IsNullOrWhiteSpace(_playerTag))
|
||
|
|
{
|
||
|
|
Debug.LogWarning("[RenderOptimizationConfig] Player Tag가 비어있습니다. 'Player'로 설정됩니다.");
|
||
|
|
_playerTag = "Player";
|
||
|
|
}
|
||
|
|
|
||
|
|
if (_checkInterval < 0.05f)
|
||
|
|
{
|
||
|
|
Debug.LogWarning("[RenderOptimizationConfig] Check Interval이 너무 짧습니다. 성능에 영향을 줄 수 있습니다.");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
#endregion
|
||
|
|
|
||
|
|
#region Factory Methods
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 기본 설정 생성
|
||
|
|
/// </summary>
|
||
|
|
public static RenderOptimizationConfig CreateDefault()
|
||
|
|
{
|
||
|
|
RenderOptimizationConfig config = CreateInstance<RenderOptimizationConfig>();
|
||
|
|
config._renderRange = 40f;
|
||
|
|
config._checkInterval = 0.2f;
|
||
|
|
config._playerTag = "Player";
|
||
|
|
config._showGizmos = true;
|
||
|
|
return config;
|
||
|
|
}
|
||
|
|
|
||
|
|
#endregion
|
||
|
|
}
|
||
|
|
}
|