Synchronously customizes the C # file template of the Unity Team program,
Sun Guangdong
Put the template developed by the Program (anyone can change and synchronize git) in the Editor folder of the unity project. After the program creates a new C # script, it is the template.
"81-C # Script-NewBehaviourScript.cs.txt" File
Using UnityEngine; using System. collections. generic; namespace DajiaGame. px {// <summary> /// Description: // author: // </summary> [AddComponentMenu ("DajiaGame/Px/# SCRIPTNAME #")] public class # SCRIPTNAME #: MonoBehaviour {// initialization function private void Start () {}// Update private void Update () per frame () {}}/ * ======================== prompt: feature-related =======================* [SerializeField] * [HideInInspector] * [RequireComponent (typeof (Rigidbody)] * [SerializeField, Range (0, 5)] int [] counts; * [SerializeField, TooltipAttribute ("Description")] * [SerializeField, HeaderAttribute ("Title")] * [SerializeField, textAreaAttribute (2, 5)] string message2; * [DisallowMultipleComponent] // The script cannot be added repeatedly * [AddComponentMenu ("DajiaGame/Px")] * [ExecuteInEditMode] */
// ------------------------------------------------------------------------- // <Copyright file = "ComAnimation. cs "company =" Game Development Laboratory "> // Copyright (c) Sprocket website ISES. all rights reserved. /// </copyright> // <author> SunGuangDong </author> /// <summary> // This is the Widget class. // </summary> // ----------------------------------------------------------------------------- using UnityEngine; using System. collections; using UnityEditor; using System. IO; namespace DajiaGame. px {// <summary> /// copy the custom C # Script Template, installation path from project Editor to Unity // sunguangdong /// </summary> public class CopyCSharpScriptTemplates: MonoBehaviour {[InitializeOnLoad] public class Startup {// D: /Program Files/Unity5/Editor/Unity.exe // D: \ Program Files \ Unity5 \ Editor \ Data \ Resources \ ScriptTemplates static Startup () {string strOriPath = Path. combine (Application. dataPath, "Editor/81-C # Script-NewBehaviourScript.cs.txt"); string strDesPath = Path. combine (Path. getDirectoryName (EditorApplication. applicationPath), "Data/Resources/ScriptTemplates/81-C # Script-NewBehaviourScript.cs.txt"); File. copy (strOriPath, strDesPath, true );}}}}
Based on the use of git or svn, the above two files will be synchronized, and each time the members restart the unity editor, the template file copy will be triggered.
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.