LoginSignup
2
1

More than 5 years have passed since last update.

あんな書式いいな、できたらいいな

Posted at

どうもAdventCalendar4回目の専門学校界の旅キチ(自称)です。

unityで新しいC#スクリプトを作ると、最初はこういった内容になっていると思います。

using UnityEngine;
using System.Collections;

public class クラス名 : MonoBehaviour {

    // Use this for initialization
    void Start () {

    }

    // Update is called once per fram 
    void Update () {

    }
}

毎回毎回Awakeの関数を書き足すのは嫌だなあ…それに中かっこの書き方も自分と違うしなあ…最初からそうなっててくれればなあ…

ちょっと待った、そのテンプレート、変えられます

Unityをインストールしたフォルダ\Unity\Editor\Data\Resources\ScriptTemplates、そこにやつは居ます。
81-C# Script-NewBehaviourScript.cs、こいつの中身を開いてみるとこうなっています。

using UnityEngine;
using System.Collections;

public class #SCRIPTNAME# : MonoBehaviour {

    // Use this for initialization
    void Start () {

    }

    // Update is called once per fram 
    void Update () {

    }
}

おおっとこいつには見覚えがある。そう、まさにこれがC#スクリプトを新規作成した際のテンプレートになるのだ。
あとはこいつを煮るなり焼くなり好きにするといい。きっとコクが増して美味しくなるだろう。

ついでに良いスパイスも教えておこう。

#region 名前
(コード)
#endregion

を挿入すれば、関数でなくとも関数のように折りたたむことが可能になる。(もちろん折りたたみ機能が存在するテキストエディタに限るが。)

環境をより良くして、更に良き開発ライフを。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1