Skip to content

Instantly share code, notes, and snippets.

@mattiemonster
Last active August 30, 2018 17:22
Show Gist options
  • Save mattiemonster/887603754ee46c9d57fb4b769e156fb1 to your computer and use it in GitHub Desktop.
Save mattiemonster/887603754ee46c9d57fb4b769e156fb1 to your computer and use it in GitHub Desktop.
Unity Editor extension to easily create all supported language files
´╗┐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