Last active
February 21, 2017 12:32
-
-
Save Wolfos/3eb651879e92cf86c2881243f7f74632 to your computer and use it in GitHub Desktop.
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
// Put this file in Assets/Editor/ | |
using UnityEngine; | |
using UnityEditor; | |
public class KeywordReplace : UnityEditor.AssetModificationProcessor | |
{ | |
public static void OnWillCreateAsset(string path) | |
{ | |
path = path.Replace(".meta", ""); | |
int index = path.LastIndexOf("."); | |
string file; | |
try | |
{ | |
file = path.Substring(index); | |
} | |
catch(System.ArgumentOutOfRangeException) | |
{ | |
return; | |
} | |
if (!file.Contains(".cs")) return; | |
index = Application.dataPath.LastIndexOf("Assets"); | |
path = Application.dataPath.Substring(0, index) + path; | |
file = System.IO.File.ReadAllText(path); | |
string[] splitPath = path.Split('/'); | |
string folder = splitPath[splitPath.Length - 2]; | |
file = file.Replace("#NAMESPACE#", folder); | |
file = file.Replace("#CREATIONDATE#", System.DateTime.Now + ""); | |
file = file.Replace("#PROJECTNAME#", PlayerSettings.productName); | |
file = file.Replace("#DEVELOPERS#", PlayerSettings.companyName); | |
System.IO.File.WriteAllText(path, file); | |
AssetDatabase.Refresh(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment