class_canvasgroup.rst 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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/4.2/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.2/doc/classes/CanvasGroup.xml.
  6. .. _class_CanvasGroup:
  7. CanvasGroup
  8. ===========
  9. **Inherits:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. Merges several 2D nodes into a single draw operation.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. Child :ref:`CanvasItem<class_CanvasItem>` nodes of a **CanvasGroup** are drawn as a single object. It allows to e.g. draw overlapping translucent 2D nodes without blending (set :ref:`CanvasItem.self_modulate<class_CanvasItem_property_self_modulate>` property of **CanvasGroup** to achieve this effect).
  15. \ **Note:** The **CanvasGroup** uses a custom shader to read from the backbuffer to draw its children. Assigning a :ref:`Material<class_Material>` to the **CanvasGroup** overrides the builtin shader. To duplicate the behavior of the builtin shader in a custom :ref:`Shader<class_Shader>` use the following:
  16. ::
  17. shader_type canvas_item;
  18. render_mode unshaded;
  19. uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest;
  20. void fragment() {
  21. vec4 c = textureLod(screen_texture, SCREEN_UV, 0.0);
  22. if (c.a > 0.0001) {
  23. c.rgb /= c.a;
  24. }
  25. COLOR *= c;
  26. }
  27. \ **Note:** Since **CanvasGroup** and :ref:`CanvasItem.clip_children<class_CanvasItem_property_clip_children>` both utilize the backbuffer, children of a **CanvasGroup** who have their :ref:`CanvasItem.clip_children<class_CanvasItem_property_clip_children>` set to anything other than :ref:`CanvasItem.CLIP_CHILDREN_DISABLED<class_CanvasItem_constant_CLIP_CHILDREN_DISABLED>` will not function correctly.
  28. .. rst-class:: classref-reftable-group
  29. Properties
  30. ----------
  31. .. table::
  32. :widths: auto
  33. +---------------------------+--------------------------------------------------------------+-----------+
  34. | :ref:`float<class_float>` | :ref:`clear_margin<class_CanvasGroup_property_clear_margin>` | ``10.0`` |
  35. +---------------------------+--------------------------------------------------------------+-----------+
  36. | :ref:`float<class_float>` | :ref:`fit_margin<class_CanvasGroup_property_fit_margin>` | ``10.0`` |
  37. +---------------------------+--------------------------------------------------------------+-----------+
  38. | :ref:`bool<class_bool>` | :ref:`use_mipmaps<class_CanvasGroup_property_use_mipmaps>` | ``false`` |
  39. +---------------------------+--------------------------------------------------------------+-----------+
  40. .. rst-class:: classref-section-separator
  41. ----
  42. .. rst-class:: classref-descriptions-group
  43. Property Descriptions
  44. ---------------------
  45. .. _class_CanvasGroup_property_clear_margin:
  46. .. rst-class:: classref-property
  47. :ref:`float<class_float>` **clear_margin** = ``10.0``
  48. .. rst-class:: classref-property-setget
  49. - void **set_clear_margin** **(** :ref:`float<class_float>` value **)**
  50. - :ref:`float<class_float>` **get_clear_margin** **(** **)**
  51. Sets the size of the margin used to expand the clearing rect of this **CanvasGroup**. This expands the area of the backbuffer that will be used by the **CanvasGroup**. A smaller margin will reduce the area of the backbuffer used which can increase performance, however if :ref:`use_mipmaps<class_CanvasGroup_property_use_mipmaps>` is enabled, a small margin may result in mipmap errors at the edge of the **CanvasGroup**. Accordingly, this should be left as small as possible, but should be increased if artifacts appear along the edges of the canvas group.
  52. .. rst-class:: classref-item-separator
  53. ----
  54. .. _class_CanvasGroup_property_fit_margin:
  55. .. rst-class:: classref-property
  56. :ref:`float<class_float>` **fit_margin** = ``10.0``
  57. .. rst-class:: classref-property-setget
  58. - void **set_fit_margin** **(** :ref:`float<class_float>` value **)**
  59. - :ref:`float<class_float>` **get_fit_margin** **(** **)**
  60. Sets the size of a margin used to expand the drawable rect of this **CanvasGroup**. The size of the **CanvasGroup** is determined by fitting a rect around its children then expanding that rect by :ref:`fit_margin<class_CanvasGroup_property_fit_margin>`. This increases both the backbuffer area used and the area covered by the **CanvasGroup** both of which can reduce performance. This should be kept as small as possible and should only be expanded when an increased size is needed (e.g. for custom shader effects).
  61. .. rst-class:: classref-item-separator
  62. ----
  63. .. _class_CanvasGroup_property_use_mipmaps:
  64. .. rst-class:: classref-property
  65. :ref:`bool<class_bool>` **use_mipmaps** = ``false``
  66. .. rst-class:: classref-property-setget
  67. - void **set_use_mipmaps** **(** :ref:`bool<class_bool>` value **)**
  68. - :ref:`bool<class_bool>` **is_using_mipmaps** **(** **)**
  69. If ``true``, calculates mipmaps for the backbuffer before drawing the **CanvasGroup** so that mipmaps can be used in a custom :ref:`ShaderMaterial<class_ShaderMaterial>` attached to the **CanvasGroup**. Generating mipmaps has a performance cost so this should not be enabled unless required.
  70. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  71. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  72. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  73. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  74. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  75. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  76. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`