WindowPartsSpotLight.cs 3.8 KB

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