unity3D 批量导出源代码

前几天 要搞软件著作权;需要源代码, 一共60页,每页50行。怎么搞 复制粘贴 60页?

想想作为程序员的我们,不应该干这么 土鳖的事情吧! 后来写了个脚本 导出所有源代码 到文件文件中,

使用之前需要在 桌面创建一个 data.txt 文件

上源码:

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

public class ExportCode : MonoBehaviour {

    public List filePath;
    public List AllDirector = new List();

 
    void Start ()
    {
        GetAllDirect(  new DirectoryInfo( Application.dataPath ) );

        GetCSFiles();
        WriteAllDate();
    }


    void WriteAllDate()
    {
        FileStream   aFile = new FileStream(@"C:\Users\join\Desktop\date.txt", FileMode.Create);
        StreamWriter sw = new StreamWriter(aFile);
        string content;
        foreach (string codePath in filePath)
        {
            content =  System.IO.File.ReadAllText(codePath);
            sw.WriteLine(content);
        }
        sw.Close();
    }


    void GetCSFiles()
    {
        foreach (DirectoryInfo info in AllDirector)
        {
            filePath.AddRange(Directory.GetFiles(info.FullName, "*.cs").ToList());
        }
    }


    void GetAllDirect( DirectoryInfo dir)
    {
        DirectoryInfo[] allDirectoryInfo = dir.GetDirectories();

        foreach (DirectoryInfo info in allDirectoryInfo)
        {
            AllDirector.Add(info);
            GetAllDirect(info);
        }

    }

}


你可能感兴趣的:(Unity,C#)