godot判断是否在编辑器内运行

示例代码:

if OS.has_feature("editor"):
            print_debug("editor")
            var cliped_image = image.get_rect(Rect2($ComposerPanel.rect_position,$ComposerPanel.rect_size))
            cliped_image.save_png("user://screenshoot.png")
else:
            print_debug("exe")
            var cliped_image = image.get_rect(Rect2($ComposerPanel.rect_position,$ComposerPanel.rect_size))
            cliped_image.save_png(OS.get_executable_path().get_base_dir() + "/screenshoot.png")

 

posted on 2026-01-07 13:21  小沙盒工作室  阅读(2)  评论(0)    收藏  举报