Last active
August 30, 2018 17:22
-
-
Save mattiemonster/887603754ee46c9d57fb4b769e156fb1 to your computer and use it in GitHub Desktop.
Unity Editor extension to easily create all supported language files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
´╗┐using UnityEditor; | |
using UnityEngine; | |
using System.IO; | |
namespace Vortex | |
{ | |
public class CreateLanguageFiles : MonoBehaviour | |
{ | |
[MenuItem("VortexDev/Text Loader/Create Language Files")] | |
public static void CreateLangFiles() | |
{ | |
Debug.Log("Creating language files in Resources folder"); | |
CreateLangFile("fallback"); | |
CreateLangFile("english"); | |
CreateLangFile("english_us"); | |
CreateLangFile("spanish"); | |
CreateLangFile("french"); | |
Debug.Log("Finished creating language files."); | |
AssetDatabase.Refresh(); // Refresh assets so new files show | |
} | |
public static void CreateLangFile(string name) | |
{ | |
Debug.Log("Creating file: " + "Assets/Resources/" + name + ".txt"); | |
if (File.Exists("Assets/Resources/" + name + ".txt")) | |
{ | |
Debug.Log("File already exists."); | |
return; | |
} | |
else | |
{ | |
FileStream fs = File.Create("Assets/Resources/" + name + ".txt"); | |
fs.Close(); | |
fs.Dispose(); | |
Debug.Log("Created file."); | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment