-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Add C# version for examples of custom BBCode tags and text effects #9420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
// Syntax: [ghost freq=5.0 span=10.0][/ghost] | ||
|
||
// Define the tag name. | ||
public string bbcode = "ghost"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should make this a constant, and it probably doesn't need to be public. Although I don't see this being used at all.
public string bbcode = "ghost"; | |
private const string Bbcode = "ghost"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to be magic - not sure how it exactly needs to be defined to be read in C# but in GDScript it just is a variable named bbcode
:
https://docs.godotengine.org/en/stable/classes/class_richtexteffect.html
This has to be tested / check RichTextEffect source code in godot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see. It looks like this only works with scripts that have a property named exactly bbcode
:
That's a weird pattern, I don't think we usually do that. For example, in editor plugins there are virtual methods for doing this kind of thing (e.g.: EditorPlugin::_get_plugin_name
).
So to make this work the member would have to be named bbcode
even though that goes against our C# naming conventions. And it can't be a constant.
Thank you, @raulsntos, for the code corrections you've provided! I've applied all of them to the examples. |
Include C# implementations for custom BBCode tags and text effects examples in "BBCode in RichTextLabel" tutorial.
Thanks once again for the providing all these adjustments, @raulsntos! I've applied them all. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should probably try following the tutorial here and see if the effect actually works as expected, especially for things like the bbcode string since it seems to be a very weirdly handled thing.
You have to use the |
Then it's probably a misconfiguration with my Godot. I've tried it on two different devices (both with the I've used |
Did you compile the C# solution? |
|
||
.. tabs:: | ||
.. code-tab:: gdscript GDScript | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No space, rather than deleting the line, GitHub doesn't allow that clearly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get it, you suggested to delete the line between the code-tab and the code itself?
@@ -931,10 +932,35 @@ Ghost | |||
char_fx.color.a = alpha | |||
return true | |||
|
|||
.. code-tab:: csharp | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
What I did
Closes: #9334