Skip to content

Instantly share code, notes, and snippets.

@me2beats
Created March 7, 2021 16:33
Show Gist options
  • Save me2beats/d6c6ff4ced33462bdb1934682a22feb4 to your computer and use it in GitHub Desktop.
Save me2beats/d6c6ff4ced33462bdb1934682a22feb4 to your computer and use it in GitHub Desktop.
Godot FileSystem utils
class_name FileSystemU
const NodeU = preload("node.gd")
static func get_tree(plugin:EditorPlugin):
var dock = plugin.get_editor_interface().get_file_system_dock()
return NodeU.get_child_by_class_path(dock, ['VSplitContainer','Tree'])
static func get_path(item:TreeItem)->String:
var res = ""
var parents = TreeU.get_parents(item)
var parents_texts = PoolStringArray()
for i in parents:
parents_texts.push_back(i.get_text(0))
if parents_texts[0] == "":
parents_texts.remove(0)
res = parents_texts.join("/")
res = res.replace("///", "//")
return res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment