WindowPartsEffectSepia.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class WindowPartsEffectSepia : WindowPartsEffectBase
  5. {
  6. public override void Awake()
  7. {
  8. base.Awake();
  9. this.sepia_tone_ = GameMain.Instance.MainCamera.GetComponent<SepiaToneEffect>();
  10. if (this.sepia_tone_ == null)
  11. {
  12. this.sepia_tone_ = GameMain.Instance.MainCamera.gameObject.AddComponent<SepiaToneEffect>();
  13. if (this.sepia_tone_.shader == null)
  14. {
  15. this.sepia_tone_.shader = Shader.Find("Hidden/Sepiatone Effect");
  16. }
  17. this.sepia_tone_.enabled = false;
  18. }
  19. }
  20. public override void OnDestroy()
  21. {
  22. if (GameMain.Instance == null || GameMain.Instance.MainCamera == null || this.sepia_tone_ == null)
  23. {
  24. return;
  25. }
  26. UnityEngine.Object.Destroy(this.sepia_tone_);
  27. this.sepia_tone_ = null;
  28. }
  29. public override void Init()
  30. {
  31. this.EnabledCheckBox.check = false;
  32. this.UpdateGui();
  33. }
  34. public override void OnSerializeEvent()
  35. {
  36. Dictionary<string, Dictionary<string, string>> woldStoreData = this.effect_window_.GetWoldStoreData();
  37. woldStoreData["Sepia"] = new Dictionary<string, string>();
  38. Dictionary<string, string> dictionary = woldStoreData["Sepia"];
  39. dictionary.Add("enabled", base.effect_enabled.ToString());
  40. }
  41. public override void OnDeserializeEvent()
  42. {
  43. Dictionary<string, Dictionary<string, string>> woldStoreData = this.effect_window_.GetWoldStoreData();
  44. if (!woldStoreData.ContainsKey("Sepia"))
  45. {
  46. WFCheckBox enabledCheckBox = this.EnabledCheckBox;
  47. bool flag = false;
  48. base.effect_enabled = flag;
  49. enabledCheckBox.check = flag;
  50. }
  51. else
  52. {
  53. Dictionary<string, string> dictionary = woldStoreData["Sepia"];
  54. base.effect_enabled = bool.Parse(dictionary["enabled"]);
  55. }
  56. this.UpdateGui();
  57. }
  58. public void UpdateGui()
  59. {
  60. this.EnabledCheckBox.check = base.effect_enabled;
  61. }
  62. protected override MonoBehaviour effect_object
  63. {
  64. get
  65. {
  66. return this.sepia_tone_;
  67. }
  68. }
  69. private SepiaToneEffect sepia_tone_;
  70. }