Can I get this inspector property to appear in a resource file
-
Hi all,
I'm storing text and a few other other parameters in resource files attached to nodes.
What I'd like is for the resource file to display the text element in the Inspector similar to the text field on the Label node to make editing text easier:
Any idea what code I need to add to my resource script to achieve this?
Cheers all. -
If you want to have your Resource display its property, you just do it using the
@export
keyword.For example,
player_data.gd
class_name PlayerData extends Resource @export var player_name := "Mario" @export var level := 1 var hidden_var := 999
Now when you create a new
PlayerData
resource in File Manager, and open that .tres file, you can see that property in Inspector.
Unless you are talking about something fancy ie., having a Label node in your Scene that syncs it text automatically to the attached resource.
-
Hi sepTN,
Thanks for coming back to me, I already have properties displayed in the Resource script which I can edit; I wondered whether there was a way to add some (editor?) code to get the inspector to show a multi-line text editor property box (similar to the one on the Label node), instead of a single line property (as shown above).The reason is that the strings being stored here will be very long - and editing and testing will be easier to have a larger area to see / read / edit the text in the Inspector.
-
Then you can just use
@export_multiline
like thisclass_name PlayerData extends Resource @export_multiline var player_name := "Mario" @export var level := 1 var hidden_var := 999
And the result
-
Perfect - thanks!