CanvasGroup
Inherits:Node2D<CanvasItem<Node<Object
Merges several 2D nodes into a single draw operation.
Description
ChildCanvasItem nodes of aCanvasGroup are drawn as a single object. It allows to e.g. draw overlapping translucent 2D nodes without blending (setCanvasItem.self_modulate property ofCanvasGroup to achieve this effect).
Note: TheCanvasGroup uses a custom shader to read from the backbuffer to draw its children. Assigning aMaterial to theCanvasGroup overrides the builtin shader. To duplicate the behavior of the builtin shader in a customShader use the following:
shader_typecanvas_item;render_modeunshaded;uniformsampler2Dscreen_texture:hint_screen_texture,repeat_disable,filter_nearest;voidfragment(){vec4c=textureLod(screen_texture,SCREEN_UV,0.0);if(c.a>0.0001){c.rgb/=c.a;}COLOR*=c;}
Note: SinceCanvasGroup andCanvasItem.clip_children both utilize the backbuffer, children of aCanvasGroup who have theirCanvasItem.clip_children set to anything other thanCanvasItem.CLIP_CHILDREN_DISABLED will not function correctly.
Properties
| ||
| ||
|
Property Descriptions
floatget_clear_margin()
Sets the size of the margin used to expand the clearing rect of thisCanvasGroup. This expands the area of the backbuffer that will be used by theCanvasGroup. A smaller margin will reduce the area of the backbuffer used which can increase performance, however ifuse_mipmaps is enabled, a small margin may result in mipmap errors at the edge of theCanvasGroup. Accordingly, this should be left as small as possible, but should be increased if artifacts appear along the edges of the canvas group.
floatget_fit_margin()
Sets the size of a margin used to expand the drawable rect of thisCanvasGroup. The size of theCanvasGroup is determined by fitting a rect around its children then expanding that rect byfit_margin. This increases both the backbuffer area used and the area covered by theCanvasGroup 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).
boolis_using_mipmaps()
Iftrue
, calculates mipmaps for the backbuffer before drawing theCanvasGroup so that mipmaps can be used in a customShaderMaterial attached to theCanvasGroup. Generating mipmaps has a performance cost so this should not be enabled unless required.