forked from zxl/LaboratoryProtection
111 lines
3.1 KiB
C#
111 lines
3.1 KiB
C#
#if UNITY_EDITOR
|
|
using Cysharp.Threading.Tasks;
|
|
|
|
using PMaker.Extension;
|
|
|
|
using Sirenix.OdinInspector;
|
|
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
using UnityEngine;
|
|
|
|
public class ScriptsTest : SerializedMonoBehaviour
|
|
{
|
|
public Object[] folders;
|
|
public string[] results;
|
|
[TextArea(4, 20)]
|
|
public string[] texts;
|
|
|
|
public bool isClearNote;
|
|
[Button]
|
|
void RunReset()
|
|
{
|
|
var searchInFolders = folders.Select(_ => UnityEditor.AssetDatabase.GetAssetPath(_)).ToArray();
|
|
//var result = AssetDatabase.FindAssets("t:Script");
|
|
var temps = UnityEditor.AssetDatabase.FindAssets("t:Script", searchInFolders);
|
|
results = temps
|
|
.Select(_ => UnityEditor.AssetDatabase.GUIDToAssetPath(_))
|
|
.Where(_ => _.Contains(".Editor") != true)
|
|
.ToArray();
|
|
UnityEditor.EditorUtility.SetDirty(this);
|
|
}
|
|
|
|
[Button]
|
|
void RunExport()
|
|
{
|
|
var str = new StringBuilder(string.Empty);
|
|
var list = new List<string>();
|
|
foreach (var item in results)
|
|
{
|
|
var value = UnityEditor.AssetDatabase.LoadAssetAtPath<TextAsset>(item);
|
|
var lines = value.text.Split('\n');
|
|
var result = lines;//.Where(_ => _.StartsWith("//") != true);
|
|
foreach (var line in result)
|
|
{
|
|
if (line == "\r" || line.Contains("using Sirenix.OdinInspector;"))
|
|
{
|
|
continue;
|
|
}
|
|
Debug.Log(line.Length);
|
|
var newStr = string.Empty;
|
|
if (isClearNote == true)
|
|
{
|
|
var begin = line.IndexOf("//");
|
|
if (begin != -1)
|
|
{
|
|
var temp = line.Substring(begin);
|
|
Debug.Log(temp);
|
|
newStr = line.Remove(begin);
|
|
}
|
|
else
|
|
{
|
|
newStr = line;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
newStr = line;
|
|
}
|
|
str.Append("\n" + newStr);
|
|
}
|
|
}
|
|
var stream = File.CreateText(Application.dataPath + "/123.txt");
|
|
Debug.Log(Application.dataPath);
|
|
//var regex = new Regex("^/.*$");
|
|
//var tempStr = Regex.Replace(str.ToString(), @"^/.*$", "");
|
|
//stream.Write(tempStr);
|
|
stream.Write(str.ToString());
|
|
stream.Close();
|
|
}
|
|
|
|
[Button]
|
|
void Test()
|
|
{
|
|
var value = UnityEditor.AssetDatabase.LoadAssetAtPath<TextAsset>(this.results[0]);
|
|
var lines = value.text.Split('\n');
|
|
var bytes = System.Text.Encoding.Default.GetBytes("\r");
|
|
foreach (var item in bytes)
|
|
{
|
|
Debug.Log(item);
|
|
}
|
|
Debug.Log(lines[1]);
|
|
nil = lines[1];
|
|
this.SetDirty();
|
|
foreach (var item in lines)
|
|
{
|
|
Debug.Log(item == nil);
|
|
Debug.Log(item.ToCharArray());
|
|
}
|
|
}
|
|
public string nil;
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
}
|
|
#endif |