LightMain.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System;
  2. using UnityEngine;
  3. public class LightMain : MonoBehaviour
  4. {
  5. public void Awake()
  6. {
  7. this.m_light = base.GetComponent<Light>();
  8. NDebug.Assert(this.m_light != null, "メインライトが設定されていません。");
  9. }
  10. private void Start()
  11. {
  12. this.ResetIntensity();
  13. RenderSettings.ambientLight = new Color(0f, 0f, 0f);
  14. RenderSettings.ambientIntensity = 0f;
  15. }
  16. public void OnLevelWasLoaded(int level)
  17. {
  18. RenderSettings.ambientLight = new Color(0f, 0f, 0f);
  19. RenderSettings.ambientIntensity = 0f;
  20. }
  21. public void SetRotation(Vector3 f_vRot)
  22. {
  23. base.gameObject.transform.rotation = Quaternion.Euler(f_vRot);
  24. }
  25. public void SetIntensity(float f_fVal)
  26. {
  27. this.m_light.intensity = f_fVal;
  28. }
  29. public float GetIntensity()
  30. {
  31. return this.m_light.intensity;
  32. }
  33. public void ResetIntensity()
  34. {
  35. this.m_light.intensity = 0.95f;
  36. }
  37. public void SetShadowStrength(float value)
  38. {
  39. this.m_light.shadowStrength = value;
  40. }
  41. public float GetShadowStrength()
  42. {
  43. return this.m_light.shadowStrength;
  44. }
  45. public void SetColor(Color color)
  46. {
  47. this.m_light.color = color;
  48. }
  49. public Color GetColor()
  50. {
  51. return this.m_light.color;
  52. }
  53. public void Reset()
  54. {
  55. this.SetRotation(new Vector3(40f, 180f, 18f));
  56. this.m_light.color = Color.white;
  57. this.ResetIntensity();
  58. this.m_light.shadowStrength = 0.098f;
  59. this.m_light.shadowBias = 0.01f;
  60. RenderSettings.ambientLight = new Color(0f, 0f, 0f);
  61. RenderSettings.ambientIntensity = 0f;
  62. }
  63. private Light m_light;
  64. private const float DefaultLightIntensity = 0.95f;
  65. private const float DefaultShadowStrength = 0.098f;
  66. }