BsScriptInspectorUtility.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsScriptEditorPrerequisites.h"
  5. #include "BsScriptObject.h"
  6. namespace bs
  7. {
  8. /** @addtogroup ScriptInteropEditor
  9. * @{
  10. */
  11. /**
  12. * Interop class between C++ & CLR that deals with custom inspectors. Custom inspectors allow the developer to control
  13. * exactly how certain types are displayed in the inspector window in the editor.
  14. */
  15. class BS_SCR_BED_EXPORT ScriptInspectorUtility : public ScriptObject<ScriptInspectorUtility>
  16. {
  17. public:
  18. SCRIPT_OBJ(EDITOR_ASSEMBLY, EDITOR_NS, "InspectorUtility");
  19. /** Hooks up domain reload callback. Must be called on library load. */
  20. static void startUp();
  21. /** Destroys domain reload callback. Must be called before library is unloaded. */
  22. static void shutDown();
  23. private:
  24. ScriptInspectorUtility(MonoObject* instance);
  25. /**
  26. * Reloads all assembly types and attempts to find uses of CustomInspector attribute. Old data cleared and replaced
  27. * with new.
  28. */
  29. static void reloadAssemblyData();
  30. static MonoClass* mCustomInspectorAtribute;
  31. static MonoField* mTypeField;
  32. static UnorderedMap<MonoClass*, MonoClass*> mInspectorTypes;
  33. static UnorderedMap<MonoClass*, MonoClass*> mInspectableFieldTypes;
  34. static HEvent mDomainLoadedConn;
  35. /************************************************************************/
  36. /* CLR HOOKS */
  37. /************************************************************************/
  38. static MonoObject* internal_GetCustomInspector(MonoReflectionType* reflType);
  39. static MonoReflectionType* internal_GetCustomInspectable(MonoReflectionType* reflType);
  40. };
  41. /** @} */
  42. }