BsScriptProfilerOverlayInternal.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #include "BsScriptProfilerOverlayInternal.h"
  2. #include "BsScriptMeta.h"
  3. #include "BsMonoField.h"
  4. #include "BsMonoClass.h"
  5. #include "BsMonoManager.h"
  6. #include "BsMonoUtil.h"
  7. #include "BsApplication.h"
  8. #include "BsCameraHandler.h"
  9. #include "BsScriptCameraHandler.h"
  10. namespace BansheeEngine
  11. {
  12. ScriptProfilerOverlayInternal::ScriptProfilerOverlayInternal(MonoObject* managedInstance, const SPtr<CameraHandler>& camera)
  13. :ScriptObject(managedInstance), mProfilerOverlayInternal(nullptr)
  14. {
  15. if (camera != nullptr)
  16. mProfilerOverlayInternal = bs_new<ProfilerOverlayInternal>(camera->getViewport());
  17. }
  18. ScriptProfilerOverlayInternal::~ScriptProfilerOverlayInternal()
  19. {
  20. if (mProfilerOverlayInternal != nullptr)
  21. bs_delete(mProfilerOverlayInternal);
  22. }
  23. void ScriptProfilerOverlayInternal::initRuntimeData()
  24. {
  25. metaData.scriptClass->addInternalCall("Internal_CreateInstance", &ScriptProfilerOverlayInternal::internal_CreateInstance);
  26. metaData.scriptClass->addInternalCall("Internal_SetType", &ScriptProfilerOverlayInternal::internal_SetType);
  27. metaData.scriptClass->addInternalCall("Internal_Update", &ScriptProfilerOverlayInternal::internal_Update);
  28. metaData.scriptClass->addInternalCall("Internal_DestroyInstance", &ScriptProfilerOverlayInternal::internal_DestroyInstance);
  29. }
  30. void ScriptProfilerOverlayInternal::internal_CreateInstance(MonoObject* instance, ScriptCameraHandler* camera)
  31. {
  32. SPtr<CameraHandler> cameraHandler;
  33. if (camera != nullptr)
  34. cameraHandler = camera->getInternal();
  35. ScriptProfilerOverlayInternal* nativeInstance = new (bs_alloc<ScriptProfilerOverlayInternal>()) ScriptProfilerOverlayInternal(instance, cameraHandler);
  36. }
  37. void ScriptProfilerOverlayInternal::internal_SetType(ScriptProfilerOverlayInternal* thisPtr, ProfilerOverlayType type)
  38. {
  39. if (thisPtr->mProfilerOverlayInternal != nullptr)
  40. thisPtr->mProfilerOverlayInternal->show(type);
  41. }
  42. void ScriptProfilerOverlayInternal::internal_Update(ScriptProfilerOverlayInternal* thisPtr)
  43. {
  44. if (thisPtr->mProfilerOverlayInternal != nullptr)
  45. thisPtr->mProfilerOverlayInternal->update();
  46. }
  47. void ScriptProfilerOverlayInternal::internal_DestroyInstance(ScriptProfilerOverlayInternal* thisPtr)
  48. {
  49. if (thisPtr->mProfilerOverlayInternal != nullptr)
  50. {
  51. bs_delete(thisPtr->mProfilerOverlayInternal);
  52. thisPtr->mProfilerOverlayInternal = nullptr;
  53. }
  54. }
  55. }