如何强制戈多特的纹理重新传播?
我有一个sample.png
在godot之外更改的文件
经过修改后,Godot恢复了一个信号,当收到该信号时
我希望重新进行该特定的sample.png文件
,我尝试了答案,但我想在脚本本身中重新插入并不是为其创建插件
(至少是我假设的)
我还尝试了 this 来自文档,但我不确定如何准确地使用它
EditorFileSystem.update_file("res://Assets/sample.png")
,所以如何实现所需的结果?
I have a sample.png
file which is being changed outside godot
and after it's modified, godot recives a signal and when that signal is received
I want that specific sample.png file to be reimported
I tried this answer but I want to reimport in my script itself not create a plugin for it
(atleast that's what I'm assuming it does)
I also tried this from the documents but I'm not sure how to use it exactly
EditorFileSystem.update_file("res://Assets/sample.png")
so how do I achieve the desired result?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
类
EditorFilesystem
用于插件。您将从
editorplugin
中调用get_editor_interface()
(如果您要制作插件,这将是您编写代码的地方)。这为您提供了一个editorInterface
对象,您可以在其上调用get_resource_filesystem()
,它为您提供了editorfilesystem
对象。因此,预期的用途是这样的:
顺便说一句,
editorinterface
还具有filesystem_changed
信号。尽管我不知道它有多可靠。通常您不必这样做。当您还原Godot窗口时,它将扫描为更改项目文件夹的更改。因此,您可以在进行其他工作时最小化Godot,而当您将Godot窗户返回时,它将选择变化。
实际上,唯一必须使用
scan
或scan_sources
的情况是我有一个工具脚本来编写应该导入的资源文件,我希望它立即反射。我没有制作自定义插件,而是提醒您,该插件形成工具脚本(只要在编辑器中运行),您就可以简单地创建
editorplugin
对象。例如:我还在我为您写的另一个答案中分享了这个示例标题“关于从工具脚本中保存资源”的标题。
The class
EditorFileSystem
is intended for plugins.You would call
get_editor_interface()
from anEditorPlugin
(which would be where you would be writing code if you were making a plugin). And that gives you anEditorInterface
object, on which you can callget_resource_filesystem()
which gives you anEditorFileSystem
object.So the intended use is something like this:
By the way,
EditorInterface
also has afilesystem_changed
signal. Although I don't know how reliable it is.Usually you don't have to do that. When you restore the Godot window, it will scan for changes in the project folder. So you might minimize Godot while you are working on something else and when you bring the Godot window back it will pick on the changes.
In practice, the only situations when I had to use
scan
orscan_sources
was when I had a tool script that write a resource file which should be imported, and I wanted it to reflect right away.Instead of making a custom plugin, I'll remind you that form a tool script (as long as it is running in the editor) you can simply create an
EditorPlugin
object. For example:I had also shared this example in another answer I wrote for you a while back here, it is under the title "About saving resources from tool scripts".