有没有办法在GODOT中将文件设置为只读

Is there a way to set a file to read only in GODOT

我将数据保存为游戏的一部分,使用 CSV 文件,并希望将其设置为只读以便用户无法修改它(系统专为经验不足的用户设计)。

有没有办法保存这些文件,使它们成为只读的?

不幸的是,godot 的 File API does not provide a mechanism to change file permissions. You could try using an encrypted file 似乎会阻止用户将其视为 CSV 文件(例如,默认情况下不应在其电子表格程序中打开)。但是,加密文件仍然可以被覆盖和损坏,这将阻碍喜欢挖掘游戏文件的玩家进行改装。

您可以编写支持此功能的 proposal to include permissions functionality in the File API, or write the saving code in a language other than GDScript, where you'd have access to a standard library with this functionality. You could write a GDNative 扩展。

最终你必须决定让你的系统防呆有多重要。坚定的用户找到打破常规的方法。