설명 없음
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.

AdaptiveViewDistance.cs 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. namespace UnityEngine.AdaptivePerformance
  2. {
  3. /// <summary>
  4. /// A scaler used by <see cref="AdaptivePerformanceIndexer"/> for adjusting what view distance is applied to the camera.
  5. /// </summary>
  6. public class AdaptiveViewDistance : AdaptivePerformanceScaler
  7. {
  8. float m_DefaultFarClipPlane = -1;
  9. /// <summary>
  10. /// Ensures settings are applied during startup.
  11. /// </summary>
  12. protected override void Awake()
  13. {
  14. base.Awake();
  15. if (m_Settings == null)
  16. return;
  17. ApplyDefaultSetting(m_Settings.scalerSettings.AdaptiveViewDistance);
  18. }
  19. /// <summary>
  20. /// Callback when scaler gets disabled and removed from indexer
  21. /// </summary>
  22. protected override void OnDisabled()
  23. {
  24. if (!Camera.main || m_DefaultFarClipPlane == -1)
  25. return;
  26. Camera.main.farClipPlane = m_DefaultFarClipPlane;
  27. }
  28. /// <summary>
  29. /// Callback when scaler gets enabled and added to the indexer
  30. /// </summary>
  31. protected override void OnEnabled()
  32. {
  33. if (!Camera.main)
  34. return;
  35. m_DefaultFarClipPlane = Camera.main.farClipPlane;
  36. }
  37. /// <summary>
  38. /// Callback for any level change.
  39. /// </summary>
  40. protected override void OnLevel()
  41. {
  42. if (!Camera.main)
  43. return;
  44. if (m_DefaultFarClipPlane == -1)
  45. m_DefaultFarClipPlane = Camera.main.farClipPlane;
  46. if (ScaleChanged())
  47. Camera.main.farClipPlane = Scale;
  48. }
  49. }
  50. }