class_editorresourcepreviewgenerator.rst 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/EditorResourcePreviewGenerator.xml.
  6. .. _class_EditorResourcePreviewGenerator:
  7. EditorResourcePreviewGenerator
  8. ==============================
  9. **Inherits:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. Custom generator of previews.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. Custom code to generate previews. Please check ``file_dialog/thumbnail_size`` in :ref:`EditorSettings<class_EditorSettings>` to find out the right size to do previews at.
  15. .. rst-class:: classref-reftable-group
  16. Methods
  17. -------
  18. .. table::
  19. :widths: auto
  20. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`bool<class_bool>` | :ref:`_can_generate_small_preview<class_EditorResourcePreviewGenerator_private_method__can_generate_small_preview>` **(** **)** |virtual| |const| |
  22. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`Texture2D<class_Texture2D>` | :ref:`_generate<class_EditorResourcePreviewGenerator_private_method__generate>` **(** :ref:`Resource<class_Resource>` resource, :ref:`Vector2i<class_Vector2i>` size, :ref:`Dictionary<class_Dictionary>` metadata **)** |virtual| |const| |
  24. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`Texture2D<class_Texture2D>` | :ref:`_generate_from_path<class_EditorResourcePreviewGenerator_private_method__generate_from_path>` **(** :ref:`String<class_String>` path, :ref:`Vector2i<class_Vector2i>` size, :ref:`Dictionary<class_Dictionary>` metadata **)** |virtual| |const| |
  26. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`bool<class_bool>` | :ref:`_generate_small_preview_automatically<class_EditorResourcePreviewGenerator_private_method__generate_small_preview_automatically>` **(** **)** |virtual| |const| |
  28. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`bool<class_bool>` | :ref:`_handles<class_EditorResourcePreviewGenerator_private_method__handles>` **(** :ref:`String<class_String>` type **)** |virtual| |const| |
  30. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. .. rst-class:: classref-section-separator
  32. ----
  33. .. rst-class:: classref-descriptions-group
  34. Method Descriptions
  35. -------------------
  36. .. _class_EditorResourcePreviewGenerator_private_method__can_generate_small_preview:
  37. .. rst-class:: classref-method
  38. :ref:`bool<class_bool>` **_can_generate_small_preview** **(** **)** |virtual| |const|
  39. If this function returns ``true``, the generator will call :ref:`_generate<class_EditorResourcePreviewGenerator_private_method__generate>` or :ref:`_generate_from_path<class_EditorResourcePreviewGenerator_private_method__generate_from_path>` for small previews as well.
  40. By default, it returns ``false``.
  41. .. rst-class:: classref-item-separator
  42. ----
  43. .. _class_EditorResourcePreviewGenerator_private_method__generate:
  44. .. rst-class:: classref-method
  45. :ref:`Texture2D<class_Texture2D>` **_generate** **(** :ref:`Resource<class_Resource>` resource, :ref:`Vector2i<class_Vector2i>` size, :ref:`Dictionary<class_Dictionary>` metadata **)** |virtual| |const|
  46. Generate a preview from a given resource with the specified size. This must always be implemented.
  47. Returning an empty texture is an OK way to fail and let another generator take care.
  48. Care must be taken because this function is always called from a thread (not the main thread).
  49. \ ``metadata`` dictionary can be modified to store file-specific metadata that can be used in :ref:`EditorResourceTooltipPlugin._make_tooltip_for_path<class_EditorResourceTooltipPlugin_private_method__make_tooltip_for_path>` (like image size, sample length etc.).
  50. .. rst-class:: classref-item-separator
  51. ----
  52. .. _class_EditorResourcePreviewGenerator_private_method__generate_from_path:
  53. .. rst-class:: classref-method
  54. :ref:`Texture2D<class_Texture2D>` **_generate_from_path** **(** :ref:`String<class_String>` path, :ref:`Vector2i<class_Vector2i>` size, :ref:`Dictionary<class_Dictionary>` metadata **)** |virtual| |const|
  55. Generate a preview directly from a path with the specified size. Implementing this is optional, as default code will load and call :ref:`_generate<class_EditorResourcePreviewGenerator_private_method__generate>`.
  56. Returning an empty texture is an OK way to fail and let another generator take care.
  57. Care must be taken because this function is always called from a thread (not the main thread).
  58. \ ``metadata`` dictionary can be modified to store file-specific metadata that can be used in :ref:`EditorResourceTooltipPlugin._make_tooltip_for_path<class_EditorResourceTooltipPlugin_private_method__make_tooltip_for_path>` (like image size, sample length etc.).
  59. .. rst-class:: classref-item-separator
  60. ----
  61. .. _class_EditorResourcePreviewGenerator_private_method__generate_small_preview_automatically:
  62. .. rst-class:: classref-method
  63. :ref:`bool<class_bool>` **_generate_small_preview_automatically** **(** **)** |virtual| |const|
  64. If this function returns ``true``, the generator will automatically generate the small previews from the normal preview texture generated by the methods :ref:`_generate<class_EditorResourcePreviewGenerator_private_method__generate>` or :ref:`_generate_from_path<class_EditorResourcePreviewGenerator_private_method__generate_from_path>`.
  65. By default, it returns ``false``.
  66. .. rst-class:: classref-item-separator
  67. ----
  68. .. _class_EditorResourcePreviewGenerator_private_method__handles:
  69. .. rst-class:: classref-method
  70. :ref:`bool<class_bool>` **_handles** **(** :ref:`String<class_String>` type **)** |virtual| |const|
  71. Returns ``true`` if your generator supports the resource of type ``type``.
  72. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  73. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  74. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  75. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  76. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  77. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  78. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`