CameraEffectEvent.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. using System;
  2. using UnityEngine;
  3. namespace Xft
  4. {
  5. public class CameraEffectEvent : XftEvent, IComparable<CameraEffectEvent>
  6. {
  7. public CameraEffectEvent(CameraEffectEvent.EType etype, XftEventComponent owner) : base(XEventType.CameraEffect, owner)
  8. {
  9. this.m_effectType = etype;
  10. }
  11. public int CompareTo(CameraEffectEvent otherObj)
  12. {
  13. return this.m_owner.CameraEffectPriority.CompareTo(otherObj.m_owner.CameraEffectPriority);
  14. }
  15. public XftCameraEffectComp CameraComp
  16. {
  17. get
  18. {
  19. this.m_comp = base.MyCamera.gameObject.GetComponent<XftCameraEffectComp>();
  20. if (this.m_comp == null)
  21. {
  22. this.m_comp = base.MyCamera.gameObject.AddComponent<XftCameraEffectComp>();
  23. }
  24. return this.m_comp;
  25. }
  26. }
  27. public CameraEffectEvent.EType EffectType
  28. {
  29. get
  30. {
  31. return this.m_effectType;
  32. }
  33. }
  34. public override void Initialize()
  35. {
  36. if (!this.CheckSupport())
  37. {
  38. UnityEngine.Debug.LogWarning("camera effect is not supported on this device:" + this.m_effectType);
  39. this.m_supported = false;
  40. return;
  41. }
  42. }
  43. public override void OnBegin()
  44. {
  45. if (!this.m_supported)
  46. {
  47. return;
  48. }
  49. base.OnBegin();
  50. this.CameraComp.AddEvent(this);
  51. }
  52. public override void Reset()
  53. {
  54. base.Reset();
  55. this.CameraComp.ResetEvent(this);
  56. }
  57. public virtual void ToggleCameraComponent(bool flag)
  58. {
  59. }
  60. public virtual bool CheckSupport()
  61. {
  62. return true;
  63. }
  64. public virtual void OnPreRender()
  65. {
  66. }
  67. public virtual void OnRenderImage(RenderTexture source, RenderTexture destination)
  68. {
  69. }
  70. protected CameraEffectEvent.EType m_effectType;
  71. protected XftCameraEffectComp m_comp;
  72. protected bool m_supported = true;
  73. public enum EType
  74. {
  75. RadialBlur,
  76. RadialBlurMask,
  77. Glow,
  78. GlowPerObj,
  79. ColorInverse,
  80. Glitch
  81. }
  82. }
  83. }