godotengine / godotengine/godot-docs

Explain how to use @export with custom resources

Open
#7,400 1 comment 0 reactions 0 assignees View on GitHub
area:manual enhancement
Dominant language
reStructuredText
Stars
5.7k
Forks
3.8k
Avg merge
1d 20h
Merged PRs (30d)
25

Description

### Your Godot version:
v4.0.3.stable.official [5222a99f5]

### Issue description:
The [page regarding exports](https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_exports.html) is awesome but it doesn't mention whether or how it's possible to use **custom classes or resources** with `@export` (If I understand correctly only custom resources is possible).

A simple example regarding custom resources would help a lot, e.g.:
`potion.gd`:
```
extends Resource
class_name Potion

@export var name:String
@export var effect:String
```

`example.gd` used by `example.tscn`:
```
extends Node2D
const Potion = preload("res://potion.gd")

@export var equipped:Potion
@export var pouch:Array[Potion] = []
```
![grafik](https://github.com/godotengine/godot-docs/assets/7897006/22b93345-7cce-44a7-b7e6-6bafbb6838a4)

### URL to the documentation page (if already existing):
https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_exports.html

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.