Search code examples
godotgdscript

How do I export a texture variable using _get_property_list?


I have my _get_property_list structure like this:

func _get_property_list():
    var properties = []
    properties.append({
        name = "Other",
        type = TYPE_NIL,
        hint_string = "other_",
        usage = PROPERTY_USAGE_GROUP | PROPERTY_USAGE_SCRIPT_VARIABLE
    })

    # Example of adding to the group
    properties.append({
        name = "other_height",
        type = TYPE_REAL
    })

    properties.append({
        name = "other_texture",
        type = TYPE_TEXTURE    #what will come here?
    })

    return properties

but I don't know what's the type for texture and it's not given in the docs either,

so how do I create a texture variable?

(Also, if possible please state out other TYPE_ as well which are not given in the docs)


Solution

  • You are going to say that the type is a resource. You do that with:

    type = TYPE_OBJECT,
    hint = PROPERTY_HINT_RESOURCE_TYPE
    

    And use the hint string to specify the class of the resource. Like this:

    type = TYPE_OBJECT,
    hint = PROPERTY_HINT_RESOURCE_TYPE,
    hint_string = "Texture"
    

    Be aware that it does not work well with custom types, because they are not registered in ClassDB.