项目记录10---自动添加头注释工具(周任务)

一套完整属于自己的框架正在一步步完成,太好了。
这周任务:
1.搞一套热跟新到框架里面。
2.版本控制。

3.erlang的http实现版本更新。

        下周:

暂时:做一个类似NGUI的图集管理器可以读取TexturePack打包的图集。



/**************************************************


 * 创建人   :XingHua


 * 创建时间 :2015-12-14


 * 模块名字 :AddHeadScriptWin


 * 基本功能 :


************************************************/


using UnityEngine;
using System.Collections;
using UnityEditor;
using System.IO;
using System.Collections.Generic;


public class AddHeadScriptWin : EditorWindow {
public string authorName = "XingHua";
public string ability = "";
public string sciptName = "";
void OnGUI()
{
EditorGUILayout.BeginVertical();
GUIStyle style = new GUIStyle();
style.fontSize = 20;
style.normal.textColor = new Color(2, 0, 0);   //设置字体颜色的
EditorGUILayout.LabelField (new GUIContent ("脚本名称 : " + Selection.activeObject.name),style);
EditorGUILayout.Space ();
EditorGUILayout.Space ();
authorName = EditorGUILayout.TextField("创建人:", authorName);
EditorGUILayout.Space ();
ability = EditorGUILayout.TextField("基本功能:",ability);
EditorGUILayout.EndVertical();


if (GUILayout.Button(new GUIContent("Add"), GUILayout.Width(50), GUILayout.Height(50))) {
Object obj = Selection.activeObject;


string filePath =  AssetDatabase.GetAssetPath(obj);


if(!File.Exists(filePath))
return;
FileStream file = File.Open(filePath, FileMode.Open);
StreamReader fileReader = new StreamReader(file);


List<string> listStr = new List<string>();
string strLine = fileReader.ReadLine();
while (strLine != null)
{
//Debug.Log(strLine);
listStr.Add(strLine);
strLine = fileReader.ReadLine();
}
fileReader.Close();


if(listStr.Contains("/**************************************************"))
return;


string filePathAndName = filePath.Substring(0,filePath.LastIndexOf('/')+1)+ obj.name+".cs";
//如果文件存在就删除
if (File.Exists(filePath))
{
File.Delete(filePath);
}
StreamWriter streamWriter = File.CreateText(filePathAndName);
// 注释部分
streamWriter.WriteLine("/**************************************************");
streamWriter.WriteLine("\n * 创建人   :" + authorName);
streamWriter.WriteLine("\n * 创建时间 :" + System.DateTime.Now.Year + "-" + System.DateTime.Now.Month + "-" + System.DateTime.Now.Day);
streamWriter.WriteLine("\n * 模块名字 :" + obj.name);
streamWriter.WriteLine("\n * 基本功能 :" + ability);
streamWriter.WriteLine("\n************************************************/");
streamWriter.WriteLine("");
for(int i = 0 ; i <listStr.Count ; i++)
{
streamWriter.WriteLine(listStr[i]);
}
streamWriter.Close();
AssetDatabase.Refresh();
}
}
}


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值