要删除本地文件,可以使用Unity的File类来操作文件。以下是一个示例代码来删除本地文件:
using System.IO;
using UnityEngine;
public class DeleteFile : MonoBehaviour
{
void Start()
{
string filePath = "path_to_your_file"; // 设置文件路径
if (File.Exists(filePath))
{
File.Delete(filePath); // 删除文件
Debug.Log("File deleted successfully");
}
else
{
Debug.LogError("File not found");
}
}
}
在上面的示例代码中,首先设置了要删除的文件的路径,然后检查文件是否存在,如果存在则调用File.Delete()方法来删除文件。最后在控制台输出相应的信息。
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: Unity场景管理的方法是什么