2016-09-13 30 views
1

質問がありました。私はC#Scripts用のUnitys Scriptテンプレートを見つけました。 は、そして、あなたは#SCRIPTNAME#を書くスクリプト名を取得するためには、それは次のようになります。それが正しい名前のスクリプトを作成しますが、#1 FOLDERNAME番号などの気にいらないが、だから私は右にそれを置くことができますがされているよりもUnityデフォルトの名前空間をスクリプトテンプレートに追加しますか?

using UnityEngine; 
using System.Collections; 

public class #SCRIPTNAME# : MonoBehaviour 
{ 
    void Start() 
    { 

    } 

    void Update() 
    { 

    } 
} 

スクリプトを作成するときに名前空間が正しく表示されませんか?

答えて

3

#FOLDERNAME#のような組み込みテンプレート変数はありません。

this postによれば、3つの魔法の変数しかありません。

  • "#名#"
  • "#のSCRIPTNAME#"
  • "#のSCRIPTNAME_LOWER番号"

しかし、あなたは常に、スクリプトの作成プロセスにフックし、自分で名前空間を追加することができますAssetModificationProcessorを使用してください。

Hereは、作成したスクリプトにカスタムデータを追加する例です。

//Assets/Editor/KeywordReplace.cs 
using UnityEngine; 
using UnityEditor; 
using System.Collections; 

public class KeywordReplace : 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; 
    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 + ""); 
    file = file.Replace("#PROJECTNAME#", PlayerSettings.productName); 
    file = file.Replace("#SMARTDEVELOPERS#", PlayerSettings.companyName); 

    System.IO.File.WriteAllText(path, file); 
    AssetDatabase.Refresh(); 
    } 
} 
+0

2017 Unity C#テンプレートの中には、#NOTRIM#もあります。何のためですか? –

関連する問題