猴子原創,歡迎轉載。轉載請注明: 轉載自Cocos2Der-CSDN,謝謝!
原文地址: http://blog.csdn.net/cocos2der/article/details/44957631
unity添加新腳本的時候,沒有版權文件頭信息,主要是沒有腳本創建人的姓名,在項目開發中,如果想知道這個腳本是誰寫的,呼來喚去弄半天才發現是自己寫的!!!
用習慣了xcode,所以準備給unity的新建腳本添加1個信息頭內容。
Unity自己就有新建腳本模板文件,但是這個文件里面的預定義key很少,不夠我們使用。所以需要自己添加幾個key。然后在新建腳本的時候替換這個幾個key為對應的內容。
打開模板文件 Unity.app/Contents/Resources/ScriptTemplates/81-C# Script-NewBehaviourScript.cs.txt
修改成:
//
// #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 () {
}
}
上面的就是版權頭信息,新建的腳本就這下面的效果了:
//
// 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 () {
}
}
//
// 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();
}
}
點擊Edit/Project Settings/Player,修改Company Name為所需要的名字。
OK,你也能夠自己根據需求自己修改了。
上一篇 二分查找分C++實現
下一篇 Mybatis學習筆記