Table of Contents

Class EditorResourcePicker

Godot editor's control for selecting Resource type properties.

Inheritance
EditorResourcePicker
Derived

Remarks

This Control node is used in the editor's Inspector dock to allow editing of Resource type properties. It provides options for creating, loading, saving and converting resources. Can be used with EditorInspectorPlugin to recreate the same behavior.

Note: This Control does not include any editor for the resource, as editing is controlled by the Inspector dock itself or sub-Inspectors.

Properties

base_type

The base type of allowed resource types. Can be a comma-separated list of several options.

var base_type : String = ""

Property Value

String

Remarks

editable

If true, the value can be selected and edited.

var editable : bool = true

Property Value

bool

Remarks

  • void set_editable(bool value)
  • bool is_editable

edited_resource

The edited resource value.

var edited_resource : Resource

Property Value

Resource

Remarks

toggle_mode

If true, the main button with the resource preview works in the toggle mode. Use EditorResourcePicker.set_toggle_pressed to manually set the state.

var toggle_mode : bool = false

Property Value

bool

Remarks

  • void set_toggle_mode(bool value)
  • bool is_toggle_mode

Methods

_handle_menu_selected(int)

Qualifiers: virtual

This virtual method can be implemented to handle context menu items not handled by default. See EditorResourcePicker._set_create_options.

bool _handle_menu_selected(int id)

Parameters

id int

_set_create_options(Object)

Qualifiers: virtual

This virtual method is called when updating the context menu of EditorResourcePicker. Implement this method to override the "New ..." items with your own options. menu_node is a reference to the PopupMenu node.

Note: Implement EditorResourcePicker._handle_menu_selected to handle these custom items.

void _set_create_options(Object menu_node)

Parameters

menu_node Object

get_allowed_types

Qualifiers: const

Returns a list of all allowed types and subtypes corresponding to the base_type. If the base_type is empty, an empty list is returned.

PackedStringArray get_allowed_types

set_toggle_pressed(bool)

Sets the toggle mode state for the main button. Works only if toggle_mode is set to true.

void set_toggle_pressed(bool pressed)

Parameters

pressed bool

Events

resource_changed(Resource)

Emitted when the value of the edited resource was changed.

signal resource_changed(Resource resource)

Parameters

resource Resource

resource_selected(Resource, bool)

Emitted when the resource value was set and user clicked to edit it. When inspect is true, the signal was caused by the context menu "Edit" or "Inspect" option.

signal resource_selected(Resource resource, bool inspect)

Parameters

resource Resource
inspect bool