From 78fff7292cfd5938f316dfaea7cc11e4fc570ca3 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Tue, 19 Dec 2023 17:29:49 +0100 Subject: [PATCH] Improve RichTextLabel `install_effect()` documentation --- doc/classes/RichTextEffect.xml | 2 +- doc/classes/RichTextLabel.xml | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/doc/classes/RichTextEffect.xml b/doc/classes/RichTextEffect.xml index ca95557f1b8..774fa2bf9c4 100644 --- a/doc/classes/RichTextEffect.xml +++ b/doc/classes/RichTextEffect.xml @@ -4,7 +4,7 @@ A custom effect for a [RichTextLabel]. - A custom effect for a [RichTextLabel]. + A custom effect for a [RichTextLabel], which can be loaded in the [RichTextLabel] inspector or using [method RichTextLabel.install_effect]. [b]Note:[/b] For a [RichTextEffect] to be usable, a BBCode tag must be defined as a member variable called [code]bbcode[/code] in the script. [codeblocks] [gdscript skip-lint] diff --git a/doc/classes/RichTextLabel.xml b/doc/classes/RichTextLabel.xml index c9a48e46b2f..85dea1485a0 100644 --- a/doc/classes/RichTextLabel.xml +++ b/doc/classes/RichTextLabel.xml @@ -225,7 +225,28 @@ - Installs a custom effect. [param effect] should be a valid [RichTextEffect]. + Installs a custom effect. This can also be done in the RichTextLabel inspector using the [member custom_effects] property. [param effect] should be a valid [RichTextEffect]. + Example RichTextEffect: + [codeblock] + # effect.gd + class_name MyCustomEffect + extends RichTextEffect + + var bbcode = "my_custom_effect" + + # ... + [/codeblock] + Registering the above effect in RichTextLabel from script: + [codeblock] + # rich_text_label.gd + extends RichTextLabel + + func _ready(): + install_effect(MyCustomEffect.new()) + + # Alternatively, if not using `class_name` in the script that extends RichTextEffect: + install_effect(preload("res://effect.gd").new()) + [/codeblock]