PreviewCameraEvent.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Events;
  5. using LuaInterface;
  6. [RequireComponent(typeof(Camera))]
  7. public class PreviewCameraEvent : MonoBehaviour
  8. {
  9. private LuaTable m_LuaSelf;
  10. private LuaFunction m_OnPreCullEvent;
  11. private LuaFunction m_OnPostRenderEvent;
  12. public void SetBindEvent(LuaTable luaSelf, LuaFunction preCullEvent, LuaFunction onPostRenderEvent)
  13. {
  14. m_LuaSelf = luaSelf;
  15. m_OnPreCullEvent = preCullEvent;
  16. m_OnPostRenderEvent = onPostRenderEvent;
  17. }
  18. private void OnPreCull() {
  19. if (m_OnPreCullEvent != null)
  20. {
  21. if (m_LuaSelf != null)
  22. {
  23. m_OnPreCullEvent.Call(m_LuaSelf);
  24. }
  25. else
  26. {
  27. m_OnPreCullEvent.Call();
  28. }
  29. }
  30. }
  31. private void OnPostRender() {
  32. if (m_OnPostRenderEvent != null)
  33. {
  34. if (m_LuaSelf != null)
  35. {
  36. m_OnPostRenderEvent.Call(m_LuaSelf);
  37. }
  38. else
  39. {
  40. m_OnPostRenderEvent.Call();
  41. }
  42. }
  43. }
  44. }