62 lines
2.1 KiB
C#
62 lines
2.1 KiB
C#
//using System.IO;
|
|
//using System.Text;
|
|
//using Sirenix.OdinInspector;
|
|
//using Sirenix.OdinInspector.Editor;
|
|
//using UnityEditor;
|
|
//using UnityEngine;
|
|
//
|
|
//namespace ZEditor
|
|
//{
|
|
// public class GenAssetConstEditor : OdinEditorWindow
|
|
// {
|
|
// [MenuItem("Tool/自动生成资源常量代码")]
|
|
// static void Open()
|
|
// {
|
|
// GetWindow<GenAssetConstEditor>().Show();
|
|
// }
|
|
//
|
|
// public string csName = "AssetConst";
|
|
// [FolderPath] public string folderPath = "Assets/Scripts/Hotfix/Const";
|
|
// [FolderPath] public string resPath = "Assets/Res";
|
|
// [Sirenix.OdinInspector.FilePath] public string template = "Assets/Res/AssetsConstTemplate.txt";
|
|
//
|
|
// [Button]
|
|
// public void Gen()
|
|
// {
|
|
// string path = $"{this.folderPath}/{this.csName}.cs";
|
|
//
|
|
// StringBuilder sb = new StringBuilder();
|
|
// this.Bridging(ref sb, this.resPath);
|
|
//
|
|
// var readAllText = File.ReadAllText(this.template);
|
|
// var content = readAllText.Replace("#CONSTCONTENT#", sb.ToString()).Replace("\\", "/");
|
|
// if (!File.Exists(path))
|
|
// {
|
|
// File.Create(path).Dispose();
|
|
// }
|
|
//
|
|
// File.WriteAllText(path, content);
|
|
// }
|
|
//
|
|
// void Bridging(ref StringBuilder sb, string path)
|
|
// {
|
|
// DirectoryInfo info = new DirectoryInfo(path);
|
|
// var fileInfos = info.GetFiles();
|
|
// var directoryInfos = info.GetDirectories();
|
|
// foreach (var fileInfo in fileInfos)
|
|
// {
|
|
// if (fileInfo.Name.Contains(".meta"))
|
|
// continue;
|
|
//
|
|
// string filePath = fileInfo.FullName.Substring(Application.dataPath.Length - 6);
|
|
// var name = filePath.Replace("\\", "_").Replace(".", "_");
|
|
// sb.AppendLine($"public const string {name} = @\"{filePath}\";");
|
|
// }
|
|
//
|
|
// foreach (var directoryInfo in directoryInfos)
|
|
// {
|
|
// this.Bridging(ref sb, directoryInfo.FullName);
|
|
// }
|
|
// }
|
|
// }
|
|
//} |