Skip to content

Instantly share code, notes, and snippets.

@AnidemDex
Last active February 26, 2024 09:22
Show Gist options
  • Save AnidemDex/8ff0e7aa424863574f9cb86531dc89e0 to your computer and use it in GitHub Desktop.
Save AnidemDex/8ff0e7aa424863574f9cb86531dc89e0 to your computer and use it in GitHub Desktop.
Some editor tricks that I’ve compiled from time to time

Editor Tricks

Drag and drop data

Editor tell other nodes what data is going to be passed throug some structs that are are converted to dictionaries.

These structs usually have this format:

{type, value, origin}

For now, I have identified 4 types:

for files from filesystem

{ 
  "type": "files", 
  "files": ["res://path/to/your/resource.tres"], 
  "from": @@6431:<Tree#559234967434>
}

type is "files".

String hint can be used as reference to know that user is dragging files related to any resource and is dragging them from EditorFileSystem tree (which reference is passed in from).

The file path is absolute to project folder res://, and all files are passed to "files" array.

Note: Some plugins in the future may add extra "virtual" directories like user://, but at the version of writing this guide (Godot 4) this is not common.

for nodes from scene editor

{
  "type": "nodes", 
  "nodes": [^"/root/@@very/@@long/@@editor/@@node/@@paths/YourNode"]
}

type is "nodes".

String hint can be used as reference to know that user is dragging one (or many) Node from SceneTree.

Each node path is passed in "nodes" array. Objects are not passed on this struct, but since these are supposed to be always a full path, using get_node() should not raise any error.

Never free these nodes. Other objects may rely on these references and can lead memory leaks and the whole editor crash.

for object properties`

{
  "type": "obj_property",
  "object": <ObjectClassName#ObjectID>,
  "property": &"property_name",
  "value": <Variant>
}

type is `"obj_property".

String hint can be used as reference to know that user is dragging an Object property from EditorInspector.

Object reference is passed in "object" key. It's current value (at the moment of drag) and the dragged property are passed in value and property respectively.

for resources

{
  "type": "resource",
  "resource": <ResourceClassName#ObjectID>, 
  "from": @@---:<Node#ObjectID>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment