WindowPartsPointLight.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. using System;
  2. using UnityEngine;
  3. public class WindowPartsPointLight : MonoBehaviour
  4. {
  5. public void Awake()
  6. {
  7. if (this.execAwake)
  8. {
  9. return;
  10. }
  11. this.execAwake = true;
  12. this.partsTransForm.onChangeAxisVisibleType.Add(new Action(this.OnChangeAxisVisibleType));
  13. this.intensityInput.onChangeValue.Add(delegate(WindowPartsInputSliderSet.SliderAndInputSet input_object, float val)
  14. {
  15. if (this.light == null)
  16. {
  17. return;
  18. }
  19. this.light.intensity = val;
  20. this.intensity = val;
  21. });
  22. this.rangeInput.onChangeValue.Add(delegate(WindowPartsInputSliderSet.SliderAndInputSet input_object, float val)
  23. {
  24. if (this.light == null)
  25. {
  26. return;
  27. }
  28. this.light.range = val;
  29. this.range = val;
  30. });
  31. this.colorInput.onChangeValue.Add(delegate(WindowPartsInputColorrPalette input_object, Color color)
  32. {
  33. if (this.light == null)
  34. {
  35. return;
  36. }
  37. this.light.color = color;
  38. this.color = color;
  39. this.updateButtonFunction();
  40. });
  41. }
  42. public void Init(Light light, PhotoTransTargetObject targetObject, Action updateButtonFunction)
  43. {
  44. this.Awake();
  45. this.light = light;
  46. this.targetObject = targetObject;
  47. this.updateButtonFunction = updateButtonFunction;
  48. this.partsTransForm.SetObject(targetObject.obj, new Vector3(0f, 1f, 0f), Vector3.zero, Vector3.one);
  49. this.partsTransForm.SetEnabledAxisButton(true, false);
  50. this.intensity = light.intensity;
  51. this.range = light.range;
  52. this.color = light.color;
  53. this.UpdateGui();
  54. }
  55. public void UpdateGui()
  56. {
  57. this.OnChangeAxisVisibleType();
  58. PhotoSliderAndInput sliderAndInput = this.intensityInput.GetSliderAndInput("str");
  59. PhotoSliderAndInput sliderAndInput2 = this.rangeInput.GetSliderAndInput("str");
  60. sliderAndInput.value = this.intensity;
  61. sliderAndInput2.value = this.range;
  62. this.colorInput.value = this.color;
  63. }
  64. protected void OnChangeAxisVisibleType()
  65. {
  66. if (this.targetObject == null)
  67. {
  68. return;
  69. }
  70. WindowPartsTransform.AxisVisibleType axis_visible_type = this.partsTransForm.axis_visible_type;
  71. PhotoTransTargetObject photoTransTargetObject = this.targetObject;
  72. if (axis_visible_type == WindowPartsTransform.AxisVisibleType.UnVisible || photoTransTargetObject == null || photoTransTargetObject.obj == null)
  73. {
  74. if (photoTransTargetObject.axis_obj != null)
  75. {
  76. photoTransTargetObject.axis_obj.Visible = false;
  77. }
  78. if (photoTransTargetObject.rotate_obj != null)
  79. {
  80. photoTransTargetObject.rotate_obj.Visible = false;
  81. }
  82. }
  83. else if (axis_visible_type == WindowPartsTransform.AxisVisibleType.Position)
  84. {
  85. if (photoTransTargetObject.axis_obj != null)
  86. {
  87. photoTransTargetObject.axis_obj.Visible = true;
  88. }
  89. if (photoTransTargetObject.rotate_obj != null)
  90. {
  91. photoTransTargetObject.rotate_obj.Visible = false;
  92. }
  93. }
  94. else if (axis_visible_type == WindowPartsTransform.AxisVisibleType.Rotate)
  95. {
  96. if (photoTransTargetObject.axis_obj != null)
  97. {
  98. photoTransTargetObject.axis_obj.Visible = false;
  99. }
  100. if (photoTransTargetObject.rotate_obj != null)
  101. {
  102. photoTransTargetObject.rotate_obj.Visible = true;
  103. }
  104. }
  105. }
  106. [SerializeField]
  107. private WindowPartsTransform partsTransForm;
  108. [SerializeField]
  109. private WindowPartsInputSliderSet intensityInput;
  110. [SerializeField]
  111. private WindowPartsInputSliderSet rangeInput;
  112. [SerializeField]
  113. private WindowPartsInputColorrPalette colorInput;
  114. private Light light;
  115. private PhotoTransTargetObject targetObject;
  116. private Action updateButtonFunction;
  117. private float intensity;
  118. private float range;
  119. private Color color;
  120. private bool execAwake;
  121. }