Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
CanvasGroup
繼承: Node2D < CanvasItem < Node < Object
將若干 2D 節點合併至單次繪製操作。
說明
Child CanvasItem nodes of a CanvasGroup are drawn as a single object. It allows to e.g. draw overlapping translucent 2D nodes without causing the overlapping sections to be more opaque than intended (set the CanvasItem.self_modulate property on the CanvasGroup to achieve this effect).
Note: The CanvasGroup uses a custom shader to read from the backbuffer to draw its children. Assigning a Material to the CanvasGroup overrides the built-in shader. To duplicate the behavior of the built-in shader in a custom Shader, use the following:
shader_type canvas_item;
render_mode unshaded;
uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest;
void fragment() {
vec4 c = textureLod(screen_texture, SCREEN_UV, 0.0);
if (c.a > 0.0001) {
c.rgb /= c.a;
}
COLOR *= c;
}
Note: Since CanvasGroup and CanvasItem.clip_children both utilize the backbuffer, children of a CanvasGroup who have their CanvasItem.clip_children set to anything other than CanvasItem.CLIP_CHILDREN_DISABLED will not function correctly.
屬性
|
||
|
||
|
屬性說明
設定用於擴充該 CanvasGroup 清除矩形的邊距大小。會對該 CanvasGroup 所使用的後臺緩衝的區域進行擴充。邊距較小時可以減少後臺緩衝的區域大小,從而提升性能,但如果啟用了 use_mipmaps,較小的邊距可能在該 CanvasGroup 邊緣造成 mipmap 錯誤。因此,這個值應該儘量調小,但是如果畫布組的邊緣出現問題,就應該將其調大。
設定用於擴充該 CanvasGroup 繪圖矩形的邊距大小。確定該 CanvasGroup 大小的方法是:首先框定子節點的矩形區域,然後將該矩形按照 fit_margin 進行擴展。會增大該 CanvasGroup 所使用的後臺緩衝的區域,也會增大該 CanvasGroup 所覆蓋的面積,兩者都會降低性能。這個值應該儘量調小,僅在需要時調大(例如自定義著色器效果)。
如果為 true,則會在繪製該 CanvasGroup 之前為其後臺緩衝計算 mipmap,附加到該 CanvasGroup 的自訂 ShaderMaterial 就可以使用 mipmap。Mipmap 的生成會造成性能消耗,所以應在必要時才啟用。