https://github.com/gimchuang/unityfileioutility
Simple scripts to process file I/O in Unity.
https://github.com/gimchuang/unityfileioutility
directory file input output path unity
Last synced: about 1 month ago
JSON representation
Simple scripts to process file I/O in Unity.
- Host: GitHub
- URL: https://github.com/gimchuang/unityfileioutility
- Owner: GimChuang
- Created: 2019-03-13T04:03:16.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-28T17:23:02.000Z (about 7 years ago)
- Last Synced: 2025-03-30T12:29:57.781Z (about 1 year ago)
- Topics: directory, file, input, output, path, unity
- Language: C#
- Homepage:
- Size: 19.5 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# UnityFileIOUtility
**FileIOUtility.cs** is a simple script helps process file I/O in Unity. There is a **Test_FileIOUtility** sample scene showing how to use this script.
How to Use
---
`FileIOUtility` is a public static class so you can simply access it from any other scripts.
Scripting Reference
---
```csharp
public static string GenerateFileName(string _prefix, int _index, FileExtension _extension)
```
generates a filename with your disired prefix string, index (useful for counting players in my case), file extension(currently I need only png and jpg) and system date time. For instance, calling `GenerateFileName("MyPicture", 23, FileExtension.PNG)` returns "MyPicture_00012_03-28_21-02-30.png".
```csharp
public static void SaveImage(Texture2D _texture, string _path, string _fileName, FileExtension _extension)
```
saves a Texture2D with specified filename and extension to a path.
```csharp
public static bool DoesPathExist(string _path)
```
checks if a path exists.
```csharp
public static bool IsFileLocked(string _filePath)
```
checks if a file is locked. (The file may be unavailable because it is still be written to, or being processed by another thread, or does not exist. This is from [nikunjM's answer on Stack Overflow](https://stackoverflow.com/a/46915212))
Note
---
This project use Git submodule [gm_FileIOUtility](https://github.com/GimChuang/gm_FileIOUtility). You need to call
```
git clone --recurse-submodules
```
when you clone this reposiory.