孙广东 2015.7.30
就是把程序制定好的模板(不论什么人能够更改并同步git)放到,unity项目的Editor 目录下, 当程序新建一个C#脚本后就是这个模板了。
“81-C# Script-NewBehaviourScript.cs.txt” 文件
using UnityEngine; using System.Collections.Generic; namespace DajiaGame.Px { /// <summary> /// 描写叙述: /// author: /// </summary> [AddComponentMenu("DajiaGame/Px/ #SCRIPTNAME# ")] public class #SCRIPTNAME# : MonoBehaviour { // 初始化函数 private void Start() { } // 每帧更新 private void Update() { } } } /* ===============提示: 特性相关================= * [SerializeField] * [HideInInspector] * [RequireComponent(typeof(Rigidbody))] * [SerializeField, Range(0,5)] int[] counts; * [SerializeField,TooltipAttribute("说明")] * [SerializeField,HeaderAttribute ("Title")] * [SerializeField,TextAreaAttribute(2, 5)] string message2; * [DisallowMultipleComponent] // 不能反复加入脚本 * [AddComponentMenu("DajiaGame/Px")] * [ExecuteInEditMode] */
//----------------------------------------------------------------------- // <copyright file="ComAnimation.cs" company="Game Development Laboratory"> // Copyright (c) Sprocket Enterprises. 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> /// 对定制的 C# 脚本模板拷贝。从 项目Editor到 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); } } } }
依据使用git 或者 svn 上面两个文件会被同步。 然后每次 成员 重新启动 unity 编辑器就会触发 模板文件的拷贝了
??
时间: 2024-10-05 15:54:17