mirror of
https://github.com/godotengine/godot-docs-l10n.git
synced 2025-12-31 09:49:22 +03:00
419 lines
30 KiB
ReStructuredText
419 lines
30 KiB
ReStructuredText
:github_url: hide
|
|
|
|
.. _class_EditorImportPlugin:
|
|
|
|
EditorImportPlugin
|
|
==================
|
|
|
|
**Eredita:** :ref:`ResourceImporter<class_ResourceImporter>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
|
|
|
|
Registra un importatore di risorse personalizzato nell'editor. Utilizza la classe per analizzare qualsiasi file e importarlo come un nuovo tipo di risorsa.
|
|
|
|
.. rst-class:: classref-introduction-group
|
|
|
|
Descrizione
|
|
----------------------
|
|
|
|
Gli **EditorImportPlugin** forniscono un modo per estendere la funzionalità di importazione delle risorse dell'editor. Utilizzali per importare risorse da file personalizzati o per fornire alternative agli importatori esistenti dell'editor.
|
|
|
|
Gli EditorImportPlugin funzionano associandosi a specifiche estensioni di file e a un tipo di risorsa. Vedi :ref:`_get_recognized_extensions()<class_EditorImportPlugin_private_method__get_recognized_extensions>` e :ref:`_get_resource_type()<class_EditorImportPlugin_private_method__get_resource_type>`. Possono facoltativamente specificare alcune preimpostazioni di importazione che influenzano il processo di importazione. Gli EditorImportPlugin sono responsabili della creazione delle risorse e del loro salvataggio nella cartella ``.godot/imported`` (vedi :ref:`ProjectSettings.application/config/use_hidden_project_data_directory<class_ProjectSettings_property_application/config/use_hidden_project_data_directory>`).
|
|
|
|
Di seguito è riportato un esempio di EditorImportPlugin che importa una :ref:`Mesh<class_Mesh>` da un file con l'estensione ".special" o ".spec":
|
|
|
|
|
|
.. tabs::
|
|
|
|
.. code-tab:: gdscript
|
|
|
|
@tool
|
|
extends EditorImportPlugin
|
|
|
|
func _get_importer_name():
|
|
return "my.special.plugin"
|
|
|
|
func _get_visible_name():
|
|
return "Special Mesh"
|
|
|
|
func _get_recognized_extensions():
|
|
return ["special", "spec"]
|
|
|
|
func _get_save_extension():
|
|
return "mesh"
|
|
|
|
func _get_resource_type():
|
|
return "Mesh"
|
|
|
|
func _get_preset_count():
|
|
return 1
|
|
|
|
func _get_preset_name(preset_index):
|
|
return "Default"
|
|
|
|
func _get_import_options(path, preset_index):
|
|
return [{"name": "my_option", "default_value": false}]
|
|
|
|
func _import(source_file, save_path, options, platform_variants, gen_files):
|
|
var file = FileAccess.open(source_file, FileAccess.READ)
|
|
if file == null:
|
|
return FAILED
|
|
var mesh = ArrayMesh.new()
|
|
# Riempi la Mesh con i dati letti in "file", lasciati come esercizio al lettore.
|
|
|
|
var filename = save_path + "." + _get_save_extension()
|
|
return ResourceSaver.save(mesh, filename)
|
|
|
|
.. code-tab:: csharp
|
|
|
|
using Godot;
|
|
|
|
public partial class MySpecialPlugin : EditorImportPlugin
|
|
{
|
|
public override string _GetImporterName()
|
|
{
|
|
return "my.special.plugin";
|
|
}
|
|
|
|
public override string _GetVisibleName()
|
|
{
|
|
return "Special Mesh";
|
|
}
|
|
|
|
public override string[] _GetRecognizedExtensions()
|
|
{
|
|
return ["special", "spec"];
|
|
}
|
|
|
|
public override string _GetSaveExtension()
|
|
{
|
|
return "mesh";
|
|
}
|
|
|
|
public override string _GetResourceType()
|
|
{
|
|
return "Mesh";
|
|
}
|
|
|
|
public override int _GetPresetCount()
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
public override string _GetPresetName(int presetIndex)
|
|
{
|
|
return "Default";
|
|
}
|
|
|
|
public override Godot.Collections.Array<Godot.Collections.Dictionary> _GetImportOptions(string path, int presetIndex)
|
|
{
|
|
return
|
|
[
|
|
new Godot.Collections.Dictionary
|
|
{
|
|
{ "name", "myOption" },
|
|
{ "default_value", false },
|
|
},
|
|
];
|
|
}
|
|
|
|
public override Error _Import(string sourceFile, string savePath, Godot.Collections.Dictionary options, Godot.Collections.Array<string> platformVariants, Godot.Collections.Array<string> genFiles)
|
|
{
|
|
using var file = FileAccess.Open(sourceFile, FileAccess.ModeFlags.Read);
|
|
if (file.GetError() != Error.Ok)
|
|
{
|
|
return Error.Failed;
|
|
}
|
|
|
|
var mesh = new ArrayMesh();
|
|
// Riempi la Mesh con i dati letti in "file", lasciati come esercizio al lettore.
|
|
string filename = $"{savePath}.{_GetSaveExtension()}";
|
|
return ResourceSaver.Save(mesh, filename);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
Per utilizzare **EditorImportPlugin**, registrarlo prima attraverso il metodo :ref:`EditorPlugin.add_import_plugin()<class_EditorPlugin_method_add_import_plugin>`.
|
|
|
|
.. rst-class:: classref-introduction-group
|
|
|
|
Tutorial
|
|
----------------
|
|
|
|
- :doc:`Estensioni di esportazione <../tutorials/plugins/editor/import_plugins>`
|
|
|
|
.. rst-class:: classref-reftable-group
|
|
|
|
Metodi
|
|
------------
|
|
|
|
.. table::
|
|
:widths: auto
|
|
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`_can_import_threaded<class_EditorImportPlugin_private_method__can_import_threaded>`\ (\ ) |virtual| |const| |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`_get_format_version<class_EditorImportPlugin_private_method__get_format_version>`\ (\ ) |virtual| |const| |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Array<class_Array>`\[:ref:`Dictionary<class_Dictionary>`\] | :ref:`_get_import_options<class_EditorImportPlugin_private_method__get_import_options>`\ (\ path\: :ref:`String<class_String>`, preset_index\: :ref:`int<class_int>`\ ) |virtual| |required| |const| |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`_get_import_order<class_EditorImportPlugin_private_method__get_import_order>`\ (\ ) |virtual| |const| |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`String<class_String>` | :ref:`_get_importer_name<class_EditorImportPlugin_private_method__get_importer_name>`\ (\ ) |virtual| |required| |const| |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`_get_option_visibility<class_EditorImportPlugin_private_method__get_option_visibility>`\ (\ path\: :ref:`String<class_String>`, option_name\: :ref:`StringName<class_StringName>`, options\: :ref:`Dictionary<class_Dictionary>`\ ) |virtual| |const| |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`_get_preset_count<class_EditorImportPlugin_private_method__get_preset_count>`\ (\ ) |virtual| |const| |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`String<class_String>` | :ref:`_get_preset_name<class_EditorImportPlugin_private_method__get_preset_name>`\ (\ preset_index\: :ref:`int<class_int>`\ ) |virtual| |required| |const| |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`float<class_float>` | :ref:`_get_priority<class_EditorImportPlugin_private_method__get_priority>`\ (\ ) |virtual| |const| |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`_get_recognized_extensions<class_EditorImportPlugin_private_method__get_recognized_extensions>`\ (\ ) |virtual| |required| |const| |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`String<class_String>` | :ref:`_get_resource_type<class_EditorImportPlugin_private_method__get_resource_type>`\ (\ ) |virtual| |required| |const| |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`String<class_String>` | :ref:`_get_save_extension<class_EditorImportPlugin_private_method__get_save_extension>`\ (\ ) |virtual| |required| |const| |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`String<class_String>` | :ref:`_get_visible_name<class_EditorImportPlugin_private_method__get_visible_name>`\ (\ ) |virtual| |required| |const| |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`_import<class_EditorImportPlugin_private_method__import>`\ (\ source_file\: :ref:`String<class_String>`, save_path\: :ref:`String<class_String>`, options\: :ref:`Dictionary<class_Dictionary>`, platform_variants\: :ref:`Array<class_Array>`\[:ref:`String<class_String>`\], gen_files\: :ref:`Array<class_Array>`\[:ref:`String<class_String>`\]\ ) |virtual| |required| |const| |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`append_import_external_resource<class_EditorImportPlugin_method_append_import_external_resource>`\ (\ path\: :ref:`String<class_String>`, custom_options\: :ref:`Dictionary<class_Dictionary>` = {}, custom_importer\: :ref:`String<class_String>` = "", generator_parameters\: :ref:`Variant<class_Variant>` = null\ ) |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
Descrizioni dei metodi
|
|
--------------------------------------------
|
|
|
|
.. _class_EditorImportPlugin_private_method__can_import_threaded:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`bool<class_bool>` **_can_import_threaded**\ (\ ) |virtual| |const| :ref:`🔗<class_EditorImportPlugin_private_method__can_import_threaded>`
|
|
|
|
Tells whether this importer can be run in parallel on threads, or, on the contrary, it's only safe for the editor to call it from the main thread, for one file at a time.
|
|
|
|
If this importer's implementation is thread-safe and can be run in parallel, override this with ``true`` to optimize for concurrency.
|
|
|
|
If not overridden, returns ``false``.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_EditorImportPlugin_private_method__get_format_version:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`int<class_int>` **_get_format_version**\ (\ ) |virtual| |const| :ref:`🔗<class_EditorImportPlugin_private_method__get_format_version>`
|
|
|
|
Gets the format version of this importer. Increment this version when making incompatible changes to the format of the imported resources.
|
|
|
|
If not overridden, the format version is ``0``.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_EditorImportPlugin_private_method__get_import_options:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Array<class_Array>`\[:ref:`Dictionary<class_Dictionary>`\] **_get_import_options**\ (\ path\: :ref:`String<class_String>`, preset_index\: :ref:`int<class_int>`\ ) |virtual| |required| |const| :ref:`🔗<class_EditorImportPlugin_private_method__get_import_options>`
|
|
|
|
Ottiene le opzioni e i valori predefiniti per la preimpostazione a questo indice. Restituisce un array di dizionari con le seguenti chiavi: ``name``, ``default_value``, ``property_hint`` (facoltativo), ``hint_string`` (facoltativo), ``usage`` (facoltativo).
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_EditorImportPlugin_private_method__get_import_order:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`int<class_int>` **_get_import_order**\ (\ ) |virtual| |const| :ref:`🔗<class_EditorImportPlugin_private_method__get_import_order>`
|
|
|
|
Ottiene l'ordine di questo importatore da eseguire durante l'importazione di risorse. Gli importatori con ordini di importazione *più bassi* saranno chiamati per primi, mentre quelli con valori più alti saranno chiamati in seguito. Utilizza questo per assicurarti che l'importatore sia eseguito dopo che le dipendenze sono già state importate. L'ordine di importazione predefinito è ``0`` a meno che non sia sovrascritto da un importatore specifico. Consulta :ref:`ImportOrder<enum_ResourceImporter_ImportOrder>` per alcuni valori predefiniti.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_EditorImportPlugin_private_method__get_importer_name:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`String<class_String>` **_get_importer_name**\ (\ ) |virtual| |required| |const| :ref:`🔗<class_EditorImportPlugin_private_method__get_importer_name>`
|
|
|
|
Ottiene il nome univoco dell'importatore.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_EditorImportPlugin_private_method__get_option_visibility:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`bool<class_bool>` **_get_option_visibility**\ (\ path\: :ref:`String<class_String>`, option_name\: :ref:`StringName<class_StringName>`, options\: :ref:`Dictionary<class_Dictionary>`\ ) |virtual| |const| :ref:`🔗<class_EditorImportPlugin_private_method__get_option_visibility>`
|
|
|
|
Determina se bisogna mostrare l'opzione di importazione specificata da ``option_name`` nel pannello Importazione. L'implementazione predefinita restituisce sempre ``true``, rendendo visibili tutte le opzioni. È utile principalmente per nascondere le opzioni che dipendono da altre se una di esse è disabilitata.
|
|
|
|
|
|
.. tabs::
|
|
|
|
.. code-tab:: gdscript
|
|
|
|
func _get_option_visibility(path, option_name, options):
|
|
# Mostra solo l'impostazione della qualità lossy se la modalità di compressione è impostata su "Lossy".
|
|
if option_name == "compress/lossy_quality" and options.has("compress/mode"):
|
|
return int(options["compress/mode"]) == COMPRESS_LOSSY # Questa è una costante che imposti
|
|
|
|
return true
|
|
|
|
.. code-tab:: csharp
|
|
|
|
public override bool _GetOptionVisibility(string path, StringName optionName, Godot.Collections.Dictionary options)
|
|
{
|
|
// Mostra solo l'impostazione della qualità lossy se la modalità di compressione è impostata su "Lossy".
|
|
if (optionName == "compress/lossy_quality" && options.ContainsKey("compress/mode"))
|
|
{
|
|
return (int)options["compress/mode"] == CompressLossy; // Questa è una costante che imposti
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_EditorImportPlugin_private_method__get_preset_count:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`int<class_int>` **_get_preset_count**\ (\ ) |virtual| |const| :ref:`🔗<class_EditorImportPlugin_private_method__get_preset_count>`
|
|
|
|
Gets the number of initial presets defined by the plugin. Use :ref:`_get_import_options()<class_EditorImportPlugin_private_method__get_import_options>` to get the default options for the preset and :ref:`_get_preset_name()<class_EditorImportPlugin_private_method__get_preset_name>` to get the name of the preset.
|
|
|
|
By default, there are no presets.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_EditorImportPlugin_private_method__get_preset_name:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`String<class_String>` **_get_preset_name**\ (\ preset_index\: :ref:`int<class_int>`\ ) |virtual| |required| |const| :ref:`🔗<class_EditorImportPlugin_private_method__get_preset_name>`
|
|
|
|
Ottiene il nome del preset delle opzioni a questo indice.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_EditorImportPlugin_private_method__get_priority:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`float<class_float>` **_get_priority**\ (\ ) |virtual| |const| :ref:`🔗<class_EditorImportPlugin_private_method__get_priority>`
|
|
|
|
Ottiene la priorità di questa estensione per l'estensione riconosciuta. Le estensioni con priorità più alta saranno preferiti. La priorità predefinita è ``1.0``.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_EditorImportPlugin_private_method__get_recognized_extensions:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`PackedStringArray<class_PackedStringArray>` **_get_recognized_extensions**\ (\ ) |virtual| |required| |const| :ref:`🔗<class_EditorImportPlugin_private_method__get_recognized_extensions>`
|
|
|
|
Ottiene la lista delle estensioni di file da associare a questo caricatore (senza distinzione tra maiuscole e minuscole). Ad esempio ``["obj"]``.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_EditorImportPlugin_private_method__get_resource_type:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`String<class_String>` **_get_resource_type**\ (\ ) |virtual| |required| |const| :ref:`🔗<class_EditorImportPlugin_private_method__get_resource_type>`
|
|
|
|
Ottiene il tipo di risorsa di Godot associato a questo caricatore, ad esempio ``"Mesh"`` o ``"Animation"``.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_EditorImportPlugin_private_method__get_save_extension:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`String<class_String>` **_get_save_extension**\ (\ ) |virtual| |required| |const| :ref:`🔗<class_EditorImportPlugin_private_method__get_save_extension>`
|
|
|
|
Ottiene l'estensione utilizzata per salvare questa risorsa nella cartella ``.godot/imported`` (vedi :ref:`ProjectSettings.application/config/use_hidden_project_data_directory<class_ProjectSettings_property_application/config/use_hidden_project_data_directory>`).
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_EditorImportPlugin_private_method__get_visible_name:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`String<class_String>` **_get_visible_name**\ (\ ) |virtual| |required| |const| :ref:`🔗<class_EditorImportPlugin_private_method__get_visible_name>`
|
|
|
|
Ottiene il nome da visualizzare nella finestra di importazione. Dovresti scegliere questo nome come continuazione di "Importa come", ad esempio "Importa come Mesh speciale".
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_EditorImportPlugin_private_method__import:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Error<enum_@GlobalScope_Error>` **_import**\ (\ source_file\: :ref:`String<class_String>`, save_path\: :ref:`String<class_String>`, options\: :ref:`Dictionary<class_Dictionary>`, platform_variants\: :ref:`Array<class_Array>`\[:ref:`String<class_String>`\], gen_files\: :ref:`Array<class_Array>`\[:ref:`String<class_String>`\]\ ) |virtual| |required| |const| :ref:`🔗<class_EditorImportPlugin_private_method__import>`
|
|
|
|
Importa ``source_file`` con le opzioni di importazione ``options``. Dovrebbe restituire :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` se l'importazione ha avuto successo, altri valori indicano un errore.
|
|
|
|
La risorsa importata si dovrebbe salvare in ``save_path + "." + _get_save_extension()``. Se si preferisce una variante diversa per un :doc:`tag di funzionalità <../tutorials/export/feature_tags>`, salvare la variante in ``save_path + "." + tag + "." + _get_save_extension()`` e aggiungere il tag di funzionalità a ``platform_variants``.
|
|
|
|
Se vengono generati file di risorse aggiuntivi nel file system delle risorse (``res://``), aggiungere il loro percorso completo a ``gen_files`` in modo che l'editor sappia che dipendono da ``source_file``.
|
|
|
|
Questo metodo si deve sovrascrivere per eseguire l'importazione effettiva. Per un esempio di come sovrascrivere questo metodo, vedere la descrizione di questa classe.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_EditorImportPlugin_method_append_import_external_resource:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Error<enum_@GlobalScope_Error>` **append_import_external_resource**\ (\ path\: :ref:`String<class_String>`, custom_options\: :ref:`Dictionary<class_Dictionary>` = {}, custom_importer\: :ref:`String<class_String>` = "", generator_parameters\: :ref:`Variant<class_Variant>` = null\ ) :ref:`🔗<class_EditorImportPlugin_method_append_import_external_resource>`
|
|
|
|
Questa funzione può essere chiamata solo durante il callback :ref:`_import()<class_EditorImportPlugin_private_method__import>` e consente di importare manualmente risorse da essa. Ciò è utile quando il file importato genera risorse esterne che richiedono un'importazione (ad esempio, immagini). È possibile passare parametri personalizzati per il file ".import" tramite ``custom_options``. Inoltre, nei casi in cui più importatori possono gestire un file, è possibile specificare ``custom_importer`` per forzarne uno specifico. Questa funzione effettua un'importazione di risorse e restituisce immediatamente un codice di successo o di errore. ``generator_parameters`` definisce ulteriori metadati facoltativi che verranno memorizzati come ``generator_parameters`` nella sezione ``remap`` del file ``.import``, ad esempio per archiviare un hash md5 dei dati di origine.
|
|
|
|
.. |virtual| replace:: :abbr:`virtual (Questo metodo dovrebbe solitamente essere sovrascritto dall'utente per aver un effetto.)`
|
|
.. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
|
|
.. |const| replace:: :abbr:`const (Questo metodo non ha effetti collaterali. Non modifica alcuna variabile appartenente all'istanza.)`
|
|
.. |vararg| replace:: :abbr:`vararg (Questo metodo accetta qualsiasi numero di argomenti oltre a quelli descritti qui.)`
|
|
.. |constructor| replace:: :abbr:`constructor (Questo metodo è utilizzato per creare un tipo.)`
|
|
.. |static| replace:: :abbr:`static (Questo metodo non necessita di alcun'istanza per essere chiamato, quindi può essere chiamato direttamente usando il nome della classe.)`
|
|
.. |operator| replace:: :abbr:`operator (Questo metodo descrive un operatore valido da usare con questo tipo come operando di sinistra.)`
|
|
.. |bitfield| replace:: :abbr:`BitField (Questo valore è un intero composto da una maschera di bit dei seguenti flag.)`
|
|
.. |void| replace:: :abbr:`void (Nessun valore restituito.)`
|