/// <summary> /// Enable's ot disable's script define line /// </summary> /// <param name="file">path to a script file</param> /// <param name="define">defined name</param> /// <param name="isEnabled">new define state</param> public static void ChangeScriptDefineState(string file, string define, bool isEnabled) { if (SA_FilesUtil.IsFileExists(file)) { string content = SA_FilesUtil.Read(file); int endlineIndex; endlineIndex = content.IndexOf(System.Environment.NewLine, System.StringComparison.CurrentCulture); if (endlineIndex == -1) { endlineIndex = content.IndexOf("\n", System.StringComparison.CurrentCulture); } string TagLine = content.Substring(0, endlineIndex); if (isEnabled) { content = content.Replace(TagLine, "#define " + define); } else { content = content.Replace(TagLine, "//#define " + define); } SA_FilesUtil.Write(file, content); } }
private static string GetStringVersionId(string versionFilePath) { if (SA_FilesUtil.IsFileExists(versionFilePath)) { return(SA_FilesUtil.Read(versionFilePath)); } else { return("0.0"); } }
/// <summary> /// Open's script file with assosialted application. /// </summary> /// <param name="pathToScript"> Asset/ folder relative path to a script file </param> /// <param name="lineNumber"> Script line number you want to put a cursor on </param> public static void OpenScript(string pathToScript, int lineNumber) { #if UNITY_EDITOR if (SA_FilesUtil.IsFileExists(pathToScript)) { var script = AssetDatabase.LoadAssetAtPath <MonoScript>(pathToScript); AssetDatabase.OpenAsset(script.GetInstanceID(), lineNumber); } else { Debug.LogError("Script you trying to open doesn't exist: " + pathToScript); } #endif }
public static void ChangeFileDefine(string file, string tag, bool isEnabled) { if (SA_FilesUtil.IsFileExists(file)) { var defineLine = "#define " + tag; if (!isEnabled) { defineLine = "//" + defineLine; } string[] content = SA_FilesUtil.ReadAllLines(file); content[0] = defineLine; SA_FilesUtil.WriteAllLines(file, content); } else { Debug.LogError(file + " not found"); } }
public static void LoadLocalGamesIds() { string rawData = SA_FilesUtil.Read(AN_Settings.ANDROID_GAMES_IDS_FILE_PATH); s_gamesIds = new AN_GamesIds(rawData); }
public static void OverrideGamesIds(string data) { SA_FilesUtil.Write(AN_Settings.ANDROID_GAMES_IDS_FILE_PATH, data); SA_AssetDatabase.ImportAsset(AN_Settings.ANDROID_GAMES_IDS_FILE_PATH); }
/// <summary> /// Returns the names of subdirectories (including their paths) in the specified directory. /// </summary> /// <returns>The directories.</returns> /// <param name="folderPath">The relative path to the directory to search. This string is not case-sensitive..</param> public static string[] GetDirectories(string folderPath) { folderPath = FixRelativePath(folderPath); return(SA_FilesUtil.GetDirectories(folderPath)); }
private static int GetVersionCode(string versionFilePath) { string stringVersionId = SA_FilesUtil.Read(versionFilePath); return(ParceVersion(stringVersionId)); }