UnityでC#スクリプトを生成した後毎回デフォルトで書かれているコードを決まったネームスペースやregionなど、チームのルールに沿って書き直す経験はありませんか。毎回同じコードを書くのは手間ですし、うっかりルールを守れていない状態で処理を書いていたなんてこともありますよね。
この問題は自分でテンプレートをカスタマイズする事で解決する事ができます。
1. UnityEditorをダウンロードしたパスからScriptTemplatesを探す
2. 81-C# Script-NewBehaviourScript.cs.txt を好みで書き換える
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class #SCRIPTNAME# : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
#NOTRIM#
}
// Update is called once per frame
void Update()
{
#NOTRIM#
}
}
あとはUnityでスクリプト生成すると
上記で書き換えた通りにコードが書き換えられていると思います。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Common
{
/// <summary>
///
/// </summary>
public class NewBehaviourScript : MonoBehaviour
{
#region 定数
#endregion
#region 変数
#endregion
#region プロパティ
#endregion
#region ライフサイクル
void Awake()
{
}
void Start()
{
}
void Update()
{
}
void LateUpdate()
{
}
#endregion
}
}
おわりに
書き換えるだけでなくテンプレートを追加することもできます。