"example.txt");CheckFileExistence();}privatevoidCheckFileExistence(){boolfileExists=File.Exists(filePath);if(fileExists){Debug.Log("文件存在");}else{Debug.Log("文件不存在");}}}
usingUnityEngine;publicclassCheckFileExistence:MonoBehaviour{publicstringfilePath;publicvoidCheckFile(){AndroidJavaObjectfile=newAndroidJavaObject("java.io.File",filePath);boolfileExists=file.Call<bool>("exists");if(fileExists){Debug.Log("File exists!");}else{Debug.Log("File does not exist!");}}} ...
private void CheckConfigFile() { if (!File.Exists(iniPath)) { throw (new FileNotFoundException(string.Format("配置文件 {0} 不存在", iniPath))); } } } 在另一个一中创建一个ConfigInfo类型的变量 1 2 3 4 5 6 7 8 9 10 public class PhotoWallCtrl : MonoBehaviour { public ConfigInfo ...
public Tile CheckTileExits(string name) { string tempPath = string.Format("{0}{1}", "Tilemap/", name); string Path = string.Format("{0}{1}{2}", "/Resources/Tilemap/", name, ".asset"); string Lastpath = Application.dataPath + Path; if (!File.Exists(Lastpath)) { CreateExampl...
File.Exists(path)) File.Create(path ).Close(); //选择覆盖模式,每次写入数据会清除上次数据 using (StreamWriter sw = new StreamWriter(new FileStream(path , FileMode.Truncate))) { sw.Write(json); } } //读取背包数据 public void ReadBagData() { //检查文件是否存在 if (!File.Exists(path)...
import java.io.File;import com.unity3d.player.UnityPlayer;public class Install { public static boolean InstallApk(String apkPath){ File apkFile = new File(apkPath);if (apkFile.exists()) { Intent intent = new Intent(Intent.ACTION_VIEW);if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N...
{// we check if we are connected or not, we join if we are , else we initiate the connection to the server.if(PhotonNetwork.IsConnected){// #Critical we need at this point to attempt joining a Random Room. If it fails, we'll get notified in OnJoinRandomFailed() and we'll ...
Exists(dataPath)) { using (FileStream fs = File.Open(dataPath, FileMode.Open)) { BinaryFormatter bf = new BinaryFormatter(); //反序列化 var deserialize = bf.Deserialize(fs); if (deserialize != null) data = deserialize as NotesTabData; //反序列化失败 数据为空 if (data == null) { /...
{if(!Directory.Exists(path)) {return; }string[] allFiles =GetAllChildFiles(path, suffix, option);for(inti =0; i < allFiles.Length; i++) {stringfile =allFiles[i];if(file.EndsWith(".meta") || file.EndsWith("txt")) {continue; ...
if (!File.Exists(targetPath)) File.Copy(file, targetPath); } } } } #endif We use the UNITY_EDITORscripting symbolto check whether we are in the Unity Editor. We are in the Editor, so it returns true, and the code executes.