How do I advance export as PackedScene?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Multirious

You would normally export PackedScene as
export(PackedScene) var scene = preload('...')

But I want to categorize the variable, so I advance export it.

func _get_property_list() -> Array:
return [
    {
        name='scene',
        type=TYPE_OBJECT
    }
]

The thing is… there is no TYPE_PACKEDSCENE. I tried to export as TYPE_OBJECT, It just exports all objects. Image

This also happens to every kind of export that TYPE_ doesn’t have. Please, let me know if there is any better way for better categorizing export or it is coming for gdscript 4.0.

:bust_in_silhouette: Reply From: omggomb

You need to use a property hint for that:

{
    name = "asdasd",
    type = TYPE_OBJECT,
    hint = PROPERTY_HINT_RESOURCE_TYPE,
    hint_string = "PackedScene"
}

Thanks. Can I ask where did you know these? I can’t find this anywhere on the docs.

Multirious | 2021-08-15 13:28

It’s not written directly, I pieced the information together from:
Object — Godot Engine (stable) documentation in English

Which lists PropertyHints:
@GlobalScope — Godot Engine (stable) documentation in English

omggomb | 2021-08-15 14:23

Thanks for the source! This getting a lil deep

Multirious | 2021-08-15 14:26