How to modify the new Script Template-ScriptTemplates (the 15th of Unity3D development) and unity3d global script
Monkey original, reprinted. Reprinted Please note: Reprinted from the Cocos2Der-CSDN, thank you!
Address: http://blog.csdn.net/cocos2der/article/details/44957631
When adding a new script to unity, there is no copyright file header information, mainly because there is no name of the script creator. in project development, if you want to know who wrote the script, call and call for half a day to discover that it was written by yourself !!!
I am used to xcode, so I am going to add an information header to the new unity script.
Unity itself has a new script template file, but there are very few predefined keys in this file, which is not enough for us to use. Therefore, you need to add several keys by yourself. Then, replace these keys with the corresponding content when creating the script.
1. Modify the Template File
Open the template file Unity. app/Contents/Resources/ScriptTemplates/81-C # Script-NewBehaviourScript.cs.txt
To:
//// #SCRIPTNAME##FILEEXTENSION#// #PROJECTNAME#//// Created by #SMARTDEVELOPERS# on #CREATIONDATE#.////using UnityEngine;using System.Collections;public class #SCRIPTNAME# : MonoBehaviour { // Use this for initialization void Start () { } // Update is called once per frame void Update () { }}
The above is the copyright header information, and the newly created script has the following effect:
//// TestClass.cs// DomoJump//// Created by YanghuiLiu on 04/09/2015.////using UnityEngine;using System.Collections;public class TestClass : MonoBehaviour { // Use this for initialization void Start () { } // Update is called once per frame void Update () { }}
2. Add an Editor script to parse the key we added above
//// HEScriptKeywordReplace.cs// HEUnityExtensionLib//// Created by YanghuiLiu on 04/09/2015.////using UnityEngine;using UnityEditor;using System.Collections;public class HEScriptKeywordReplace : UnityEditor.AssetModificationProcessor { public static void OnWillCreateAsset ( string path ) { path = path.Replace(".meta", ""); int index = path.LastIndexOf("."); string file = path.Substring(index); if (file != ".cs" && file != ".js" && file != ".boo") return; string fileExtension = file; index = Application.dataPath.LastIndexOf("Assets"); path = Application.dataPath.Substring(0, index) + path; file = System.IO.File.ReadAllText(path); file = file.Replace("#CREATIONDATE#", System.DateTime.Now.ToString("d")); file = file.Replace("#PROJECTNAME#", PlayerSettings.productName); file = file.Replace("#SMARTDEVELOPERS#", PlayerSettings.companyName); file = file.Replace("#FILEEXTENSION#", fileExtension); System.IO.File.WriteAllText(path, file); AssetDatabase.Refresh(); }}
3. Set PlayerSettings attributes
Click Edit/Project Settings/Player to change Company Name to the desired Name.
OK. You can also modify it as needed.