SepiaToneEffectManager.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System.IO;
  2. using UnityEngine;
  3. namespace COM3D2.MeidoPhotoStudio.Plugin
  4. {
  5. public class SepiaToneEffectManger : IEffectManager
  6. {
  7. public const string header = "EFFECT_SEPIA";
  8. private SepiaToneEffect SepiaTone { get; set; }
  9. public bool Ready { get; private set; }
  10. public bool Active { get; private set; }
  11. public void Activate()
  12. {
  13. if (SepiaTone == null)
  14. {
  15. Ready = true;
  16. SepiaTone = GameMain.Instance.MainCamera.GetOrAddComponent<SepiaToneEffect>();
  17. if (SepiaTone.shader == null) SepiaTone.shader = Shader.Find("Hidden/Sepiatone Effect");
  18. }
  19. SetEffectActive(false);
  20. }
  21. public void Deactivate() => SetEffectActive(false);
  22. public void Deserialize(BinaryReader binaryReader) => SetEffectActive(binaryReader.ReadBoolean());
  23. public void Serialize(BinaryWriter binaryWriter)
  24. {
  25. binaryWriter.Write(header);
  26. binaryWriter.Write(Active);
  27. }
  28. public void SetEffectActive(bool active) => SepiaTone.enabled = Active = active;
  29. public void Reset() { }
  30. public void Update() { }
  31. }
  32. }