From b7c41f9ba1afe892af465b56cd942b83e1a19b13 Mon Sep 17 00:00:00 2001 From: reduz Date: Sun, 19 Jun 2022 00:42:02 +0200 Subject: Add ability to export Node pointers as NodePaths This PR implements: * A new hint: PROPERTY_HINT_NODE_TYPE for variant type OBJECT, which can take specific node types as hint string. * The editor will show it as a node path, but will set it as a pointer to a node from the current scene if you select a path. * When scene is saved, the node path is saved, then restored as a pointer. NOTE: This is a proof of concept and this approach will most likely not work. The reason if that, if the node referenced is deleted, then when trying to edit this the node will become invalid. Potential workarounds: Since this uses the Variant API, it should obtain the pointer from the Variant object ID. Yet, this would either only really work in GDScript or it would need to be implemented with workarounds in every language. Alternative ways to make this work: Nodes could export an additional property with a node path (like for which_node, it could be which_node_path). Another alternative: Path editing could happen as a hidden metadata (ignoring the pointer). --- core/object/object.h | 1 + 1 file changed, 1 insertion(+) (limited to 'core/object') diff --git a/core/object/object.h b/core/object/object.h index 02dd875acf..7631cc6c4c 100644 --- a/core/object/object.h +++ b/core/object/object.h @@ -91,6 +91,7 @@ enum PropertyHint { PROPERTY_HINT_INT_IS_POINTER, PROPERTY_HINT_LOCALE_ID, PROPERTY_HINT_LOCALIZABLE_STRING, + PROPERTY_HINT_NODE_TYPE, ///< a node object type PROPERTY_HINT_MAX, // When updating PropertyHint, also sync the hardcoded list in VisualScriptEditorVariableEdit }; -- cgit v1.2.3