Created
October 10, 2017 08:34
-
-
Save buijldert/ca72404defa4072d09a645395c98b989 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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