框架上传

This commit is contained in:
2025-03-31 11:16:52 +08:00
parent 7197b4c0d0
commit ffcdddbd2a
429 changed files with 19115 additions and 1579 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 10cd38fccc1db684d9a576da1f9dc85e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,40 @@
using System;
using System.IO;
namespace Stary.Evo.Editor
{
public class ChangeScriptTemplates : UnityEditor.AssetModificationProcessor
{
// 要添加的注释的内容
private static string annotationStr =
"/**************************************************** \r\n"
+ " 文件:#Filename\r\n"
+ " 作者:#CreateAuthor#\r\n"
+ " 邮箱:\r\n"
+ " 日期:#CreateTime#\r\n"
+ " 功能:\r\n"
+ "*****************************************************/\r\n\n";
public static void OnWillCreateAsset(string path)
{
//将.meta后缀屏蔽
path = path.Replace(".meta", "");
//只对.cs脚本作操作
if (path.EndsWith(".cs"))
{
//读取该路径下的.cs文件中的所有文本.
//注意此时Unity已经对脚本完成了模版内容的替换包括#SCRIPTNAME#也已经被替换为文件名了,读取到的是替换后的文本内容.
annotationStr += File.ReadAllText(path);
//获取用户名和当前系统时间并替换对应位置内容
annotationStr = annotationStr.Replace("#CreateAuthor#", Environment.UserName)
.Replace("#CreateTime#", string.Concat(DateTime.Now.Year, "/", DateTime.Now.Month, "/",
DateTime.Now.Day, " ", DateTime.Now.Hour, ":", DateTime.Now.Minute, ":", DateTime.Now.Second))
.Replace("#Filename", Path.GetFileName(path));
if (!File.ReadAllText(path).Contains("文件") && !File.ReadAllText(path).Contains("作者") && !File.ReadAllText(path).Contains("邮箱") && !File.ReadAllText(path).Contains("日期") && !File.ReadAllText(path).Contains("功能"))
//重新将文本写入.cs文件
File.WriteAllText(path, annotationStr);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 46fd7b74d162e9042a93085169ef025f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: cf3097de0b145f944931508c9e1a0bcd
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,51 @@
/****************************************************
文件CreatScriptableObject.cs
作者:张铮
邮箱834207172@qq.com
日期2022/3/7 18:26:10
功能:
*****************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using Sirenix.OdinInspector.Editor;
using Sirenix.Utilities;
using UnityEditor;
using UnityEngine;
namespace Stary.Evo.Editor
{
public class CreatScriptableObject : OdinMenuEditorWindow
{
[MenuItem("Evo/Utility/ScriptObject/查找", false, 3)]
//[MenuItem("Assets/Create Scriptable Object", priority = -1000)]
private static void ShowDialog()
{
GetWindow<CreatScriptableObject>().Show();
}
/// <summary>
/// 获取继承 ScriptableObject 且不是Editor相关的所有自定义类也就是自己编写的类
/// </summary>
// static HashSet<Type> scriptableObjectTypes = AssemblyUtilities.GetTypes(AssemblyTypeFlags.CustomTypes)
// .Where(t =>
// t.IsClass &&
// typeof(ScriptableObject).IsAssignableFrom(t) &&
// !typeof(EditorWindow).IsAssignableFrom(t) &&
// !typeof(Editor).IsAssignableFrom(t) && t.GetCustomAttribute<ScriptableObjectEditorAttribute>() != null)
// .ToHashSet();
protected override OdinMenuTree BuildMenuTree()
{
OdinMenuTree tree = new OdinMenuTree(false); //不支持多选
tree.Selection.SupportsMultiSelect = false;
tree.AddAllAssetsAtPath("预览ScriptableObject", "Assets/Domain", typeof(ScriptableObject), true, true);
// tree.AddAllAssetsAtPath("预览ScriptableObject", "Assets/~Resources", typeof(ScriptableObject), true, true);
return tree;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ef650bd595ac650469971d45500a96ea
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,204 @@
// /****************************************************
// 文件ScriptableObjectCreator.cs
// 作者:张铮
// 邮箱834207172@qq.com
// 日期2022/3/7 18:24:58
// 功能:
// *****************************************************/
//
// using System;
// using System.Collections.Generic;
// using System.IO;
// using System.Linq;
// using EditorFramework;
// using Sirenix.OdinInspector.Editor;
// using Sirenix.Utilities;
// using Sirenix.Utilities.Editor;
// using UnityEditor;
// using UnityEngine;
// using WVDFramework;
//
// public class ScriptableObjectCreator : OdinMenuEditorWindow
// {
// [MenuItem("Utility/ScriptObject/创建",false,2)]
// //[MenuItem("Assets/Create Scriptable Object", priority = -1000)]
// private static void ShowDialog()
// {
// var path = "Assets";
// var obj = Selection.activeObject; //当前鼠标选中的 Object
// if (obj && AssetDatabase.Contains(obj))
// {
// path = AssetDatabase.GetAssetPath(obj);
// if (!Directory.Exists(path)) //主要用来判断所选的是文件还是文件夹
// {
// path = Path.GetDirectoryName(path); //如果是文件则获取对应文件夹的全名称
// }
// }
//
// //设置窗口对应属性
// var window = CreateInstance<ScriptableObjectCreator>();
// window.position = GUIHelper.GetEditorWindowRect().AlignCenter(800, 500); //设置窗口的宽和高
// window.titleContent = new GUIContent(path);
// window.targetFolder = path.Trim('/'); //避免出现 / 造成路径不对
// window.ShowUtility();
// }
//
// /// <summary>
// /// 获取继承 ScriptableObject 且不是Editor相关的所有自定义类也就是自己编写的类
// /// </summary>
// private static HashSet<Type> scriptableObjectTypes = AssemblyUtilities.GetTypes(AssemblyTypeFlags.CustomTypes)
// .Where(t =>
// t.IsClass &&
// typeof(ScriptableObject).IsAssignableFrom(t) &&
// !typeof(EditorWindow).IsAssignableFrom(t) &&
// !typeof(Editor).IsAssignableFrom(t) && t.GetCustomAttribute<ScriptableObjectEditorAttribute>() != null)
// .ToHashSet();
// /// <summary>
// /// 选中的 ScriptableObject等待创建
// /// </summary>
// private ScriptableObject previewObject;
//
// /// <summary>
// /// 创建 ScriptableObject 时文件存储的目标文件夹
// /// </summary>
// private string targetFolder;
//
// private Vector2 scroll;
//
// private Type SelectedType
// {
// get
// {
// var m = MenuTree.Selection.LastOrDefault(); //因为可以多选所以返回选中的是一个列表这里返回的是列表的最后一个Object
// return m == null ? null : m.Value as Type;
// }
// }
//
// protected override OdinMenuTree BuildMenuTree()
// {
// mFolderField = new FolderField();
// OdinMenuTree tree = new OdinMenuTree(false); //不支持多选
// MenuWidth = 300; //菜单的宽度
// WindowPadding = Vector4.zero;
// tree.Config.DrawSearchToolbar = true; //开启搜索状态
// tree.DefaultMenuStyle = OdinMenuStyle.TreeViewStyle; //菜单设置成树形模式
// //筛选所有非抽象的类 并获取对应的路径
// tree.AddRange(scriptableObjectTypes.Where(x => !x.IsAbstract), GetMenuPathForType).AddThumbnailIcons();
// tree.SortMenuItemsByName();
// tree.Selection.SelectionConfirmed += x =>
// {
// Debug.Log($"双击确认并创建:{x}");
// this.CreateAsset();
// };
// tree.Selection.SelectionChanged += e =>
// {
// //每当选择发生更改时发生进行回调2次一次SelectionCleared 一次是ItemAdded
// if (this.previewObject && !AssetDatabase.Contains(this.previewObject))
// {
// DestroyImmediate(previewObject);
// }
//
// if (e != SelectionChangedType.ItemAdded)
// {
// return;
// }
//
// var t = SelectedType;
// if (t != null && !t.IsAbstract)
// {
// previewObject = CreateInstance(t) as ScriptableObject;
// }
// };
// return tree;
// }
//
// private string GetMenuPathForType(Type t)
// {
// if (t != null && scriptableObjectTypes.Contains(t))
// {
// var name = t.Name.Split('`').First()
// .SplitPascalCase(); //主要是为了去除泛型相关 例如Sirenix.Utilities.GlobalConfig`1[Sirenix.Serialization.GlobalSerializationConfig]
// return GetMenuPathForType(t.BaseType) + "/" + name;
// }
//
// return "";
// }
//
// protected override IEnumerable<object> GetTargets()
// {
// yield return previewObject;
// }
//
// private FolderField mFolderField;
//
// // private void OnEnable()
// // {
// // mFolderField = new FolderField();
// // }
//
// private string filename = default;
//
// protected override void DrawEditor(int index)
// {
// //scroll 内容滑动条的XY坐标
// scroll = GUILayout.BeginScrollView(scroll);
// {
// base.DrawEditor(index);
// }
// GUILayout.EndScrollView();
//
// if (this.previewObject)
// {
// GUILayout.FlexibleSpace(); //插入一个空隙
// SirenixEditorGUI.HorizontalLineSeparator(5); //插入一个水平分割线
// GUILayout.BeginHorizontal();
// {
// GUILayout.Label("选择要创建到的路径");
// var rect = EditorGUILayout.GetControlRect(GUILayoutOptions.Height(20));
// mFolderField.OnGUI(rect);
// }
// GUILayout.EndHorizontal();
// SirenixEditorGUI.HorizontalLineSeparator(5); //插入一个水平分割线
// GUILayout.BeginHorizontal();
// {
// GUILayout.Label("请输入要创建的文件名字");
// filename = GUILayout.TextField(filename);
// GUILayout.Label(".asset", GUILayout.MaxWidth(40));
// }
// GUILayout.EndHorizontal();
//
// SirenixEditorGUI.HorizontalLineSeparator(5); //插入一个水平分割线
// if (GUILayout.Button("Create Asset", GUILayoutOptions.Height(30)))
// {
// if (mFolderField.Path == "Assets")
// {
// if (EditorUtility.DisplayDialog("创建", ".asset文件创建在Assets目录下是否确定创建", "是", "否")) //显示对话框
// {
// CreateAsset();
// }
// }
// else
// {
// CreateAsset();
// }
// }
// }
// }
//
// private void CreateAsset()
// {
// if (previewObject)
// {
// if (filename == default)
// filename = MenuTree.Selection.First().Name.Replace(" ","");
// var dest = mFolderField.Path + filename + ".asset";
// dest = AssetDatabase.GenerateUniqueAssetPath(dest); //创建唯一路径 重名后缀 +1
// Debug.Log($"要创建的为{previewObject}");
// AssetDatabase.CreateAsset(previewObject, dest);
// AssetDatabase.SaveAssets();
// AssetDatabase.Refresh();
// Selection.activeObject = previewObject;
// EditorApplication.delayCall += Close; //如不需要创建后自动关闭可将本行注释
// }
// }
// }

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 814d860f258b17945ba74463d9d00144
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 20d2d1f263e3b9c4fb90d17963276af4
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,77 @@
/****************************************************
文件StringToLayer.cs
作者:张铮
邮箱834207172@qq.com
日期2022/3/3 17:53:52
功能:
*****************************************************/
using System.IO;
using System.Text;
using UnityEditor;
using UnityEngine;
namespace Stary.Evo.Editor
{
public class StringToLayer
{
[MenuItem("Evo/Utility/Layer和Tag转换")]
private static void Layer()
{
var sb = new StringBuilder(); //准备模板生成
sb.AppendLine("public class _Const");
sb.AppendLine("{");
for (int i = 0; i < 32; i++) //遍历所有Layer
{
var name = LayerMask.LayerToName(i); //通过Unity的接口拿到Layer名称
name = name
.Replace(" ", "_")
.Replace("&", "_")
.Replace("/", "_")
.Replace(".", "_")
.Replace(",", "_")
.Replace(";", "_")
.Replace("-", "_"); //对常见的特殊字符进行过滤
if (!string.IsNullOrEmpty(name))
sb.AppendFormat("\tpublic const int LAYER_{0} = {1};\n", name.ToUpper(), i);
}
sb.AppendLine("\tpublic const string " + ("Tag_Untagged".ToUpper() + " = "
+ "\"Untagged\";"));
sb.AppendLine("\tpublic const string " + ("Tag_Respawn".ToUpper() + " = "
+ "\"Respawn\";"));
sb.AppendLine("\tpublic const string " + ("Tag_Finish".ToUpper() + " = "
+ "\"Finish\";"));
sb.AppendLine("\tpublic const string " + ("Tag_EditorOnly".ToUpper() + "= " + "\"EditorOnly\";"));
sb.AppendLine("\tpublic const string " + ("Tag_MainCamera".ToUpper() + "= " + "\"MainCamera\";"));
sb.AppendLine("\tpublic const string " + ("Tag_Player".ToUpper() + " = "
+ "\"Player\";"));
sb.AppendLine("\tpublic const string " + ("Tag_GameController".ToUpper()
+ " = " + "\"GameController\";")); //把一部分内置Tag先写死
var asset = UnityEditor.AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset"); //取得自定义Tag
if ((asset != null) && (asset.Length > 0))
{
for (int i = 0; i < asset.Length; i++)
{
//创建序列化对象
var so = new UnityEditor.SerializedObject(asset[i]);
var tags = so.FindProperty("tags"); //读取具体字段
for (int j = 0; j < tags.arraySize; ++j)
{
var item = tags.GetArrayElementAtIndex(j).stringValue;
sb.AppendFormat("\tpublic const string TAG_{0} = \"{1}\";\n",
item.ToUpper(), item);
} //添加到模板
}
}
sb.AppendLine("}");
File.WriteAllText("Assets/HotUpdate/GeneratedConst.cs", sb.ToString()); //写入硬盘
UnityEditor.AssetDatabase.Refresh(); //通知Unity刷新
///可新增BudSetting中场景
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 42faa98f2e9e23546949a21ac1629c83
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: