123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- using wf;
- public class WindowPartsDirectionalLight : MonoBehaviour
- {
- public void Awake()
- {
- if (this.execAwake)
- {
- return;
- }
- this.execAwake = true;
- this.light_ = GameMain.Instance.MainLight;
- this.RotateInput.onChangeValue.Add(new Action<WindowPartsInputSliderSet.SliderAndInputSet, float>(this.OnChangetRotateValue));
- this.IntensityInput.onChangeValue.Add(new Action<WindowPartsInputSliderSet.SliderAndInputSet, float>(this.OnChangetIntensityValue));
- this.ShadowInput.onChangeValue.Add(new Action<WindowPartsInputSliderSet.SliderAndInputSet, float>(this.OnChangetShadowValue));
- this.ColorInput.onChangeValue.Add(new Action<WindowPartsInputColorrPalette, Color>(this.OnChangetColorValue));
- }
- public void Init(Action updateButtonFunction)
- {
- this.Awake();
- this.updateButtonFunction = updateButtonFunction;
- Vector3 eulerAngles = this.light_.transform.localRotation.eulerAngles;
- this.intensity_ = this.light_.GetIntensity();
- this.shadow_ = this.light_.GetShadowStrength();
- this.euler_angles_ = eulerAngles;
- this.color_ = this.light_.GetColor();
- PhotoSliderAndInput sliderAndInput = this.RotateInput.GetSliderAndInput("x");
- PhotoSliderAndInput sliderAndInput2 = this.RotateInput.GetSliderAndInput("y");
- PhotoSliderAndInput sliderAndInput3 = this.IntensityInput.GetSliderAndInput("str");
- PhotoSliderAndInput sliderAndInput4 = this.ShadowInput.GetSliderAndInput("str");
- sliderAndInput.ResetNum = this.euler_angles_.x;
- sliderAndInput2.ResetNum = this.euler_angles_.y;
- sliderAndInput3.ResetNum = this.intensity_;
- sliderAndInput4.ResetNum = this.shadow_;
- this.ColorInput.ResetNum = this.color_;
- this.UpdateGui();
- }
- public void SetLightWindow(LightWindow light_window)
- {
- this.light_window_ = light_window;
- }
- public void OnDestroy()
- {
- if (GameMain.Instance != null && GameMain.Instance.MainLight != null)
- {
- this.light_.Reset();
- }
- }
- public void OnChangetRotateValue(WindowPartsInputSliderSet.SliderAndInputSet input_object, float val)
- {
- if (this.light_ == null)
- {
- return;
- }
- if (input_object.Name == "x")
- {
- this.euler_angles_.x = val;
- }
- else if (input_object.Name == "y")
- {
- this.euler_angles_.y = val;
- }
- this.light_.SetRotation(this.euler_angles_);
- }
- public void OnChangetIntensityValue(WindowPartsInputSliderSet.SliderAndInputSet input_object, float val)
- {
- if (this.light_ == null)
- {
- return;
- }
- this.intensity_ = val;
- this.light_.SetIntensity(this.intensity_);
- }
- public void OnChangetShadowValue(WindowPartsInputSliderSet.SliderAndInputSet input_object, float val)
- {
- if (this.light_ == null)
- {
- return;
- }
- this.shadow_ = val;
- this.light_.SetShadowStrength(this.shadow_);
- }
- public void OnChangetColorValue(WindowPartsInputColorrPalette input_object, Color color)
- {
- if (this.light_ == null)
- {
- return;
- }
- this.color_ = color;
- this.light_.SetColor(this.color_);
- if (this.updateButtonFunction != null)
- {
- this.updateButtonFunction();
- }
- }
- public void UpdateGui()
- {
- PhotoSliderAndInput sliderAndInput = this.RotateInput.GetSliderAndInput("x");
- PhotoSliderAndInput sliderAndInput2 = this.RotateInput.GetSliderAndInput("y");
- PhotoSliderAndInput sliderAndInput3 = this.IntensityInput.GetSliderAndInput("str");
- PhotoSliderAndInput sliderAndInput4 = this.ShadowInput.GetSliderAndInput("str");
- sliderAndInput.value = this.euler_angles_.x;
- sliderAndInput2.value = this.euler_angles_.y;
- sliderAndInput3.value = this.intensity_;
- sliderAndInput4.value = this.shadow_;
- this.ColorInput.value = this.color_;
- }
- public void OnSerializeEvent()
- {
- Dictionary<string, Dictionary<string, string>> woldStoreData = this.light_window_.GetWoldStoreData();
- woldStoreData["DirectionalLight"] = new Dictionary<string, string>();
- Dictionary<string, string> dictionary = woldStoreData["DirectionalLight"];
- dictionary.Add("intensity", this.intensity_.ToString("G9"));
- dictionary.Add("euler_angles", this.euler_angles_.ToString("G9"));
- dictionary.Add("shadow", this.shadow_.ToString("G9"));
- dictionary.Add("color", this.color_.ToString("G9"));
- }
- public void OnDeserializeEvent()
- {
- Dictionary<string, Dictionary<string, string>> woldStoreData = this.light_window_.GetWoldStoreData();
- if (!woldStoreData.ContainsKey("DirectionalLight"))
- {
- this.light_.Reset();
- this.intensity_ = this.light_.GetIntensity();
- this.shadow_ = this.light_.GetShadowStrength();
- this.euler_angles_ = this.light_.transform.localRotation.eulerAngles;
- this.color_ = this.light_.GetColor();
- }
- else
- {
- Dictionary<string, string> dictionary = woldStoreData["DirectionalLight"];
- this.intensity_ = float.Parse(dictionary["intensity"]);
- this.euler_angles_ = Parse.Vector3(dictionary["euler_angles"]);
- this.shadow_ = float.Parse(dictionary["shadow"]);
- this.color_ = Parse.Color(dictionary["color"]);
- }
- this.UpdateGui();
- }
- public bool visible
- {
- get
- {
- return base.gameObject.activeSelf;
- }
- set
- {
- base.gameObject.SetActive(true);
- }
- }
- public WindowPartsInputSliderSet RotateInput;
- public WindowPartsInputSliderSet IntensityInput;
- public WindowPartsInputSliderSet ShadowInput;
- public WindowPartsInputColorrPalette ColorInput;
- private Action updateButtonFunction;
- private bool execAwake;
- private LightMain light_;
- private Vector3 euler_angles_;
- private float intensity_;
- private float shadow_;
- private Color color_;
- private LightWindow light_window_;
- }
|