初始化

This commit is contained in:
come
2025-07-26 16:56:42 +08:00
parent 8291dbb91c
commit fa81439a8c
2574 changed files with 328492 additions and 2170 deletions

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ba64967cec9c48b1b4c09f76127a2895
timeCreated: 1683359859

View File

@@ -0,0 +1,85 @@
#if UNITY_EDITOR
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Sirenix.OdinInspector.Editor;
using UnityEditor;
namespace YIUIFramework.Editor
{
/// <summary>
/// 奥丁扩展
/// </summary>
public static class OdinMenuTree_Extensions
{
//仿照源码扩展的 根据 AssetImporter 类型
public static IEnumerable<OdinMenuItem> AddAllAssetImporterAtPath(
this OdinMenuTree tree,
string menuPath,
string assetFolderPath,
System.Type type,
bool includeSubDirectories = false,
bool flattenSubDirectories = false)
{
assetFolderPath = (assetFolderPath ?? "").TrimEnd('/') + "/";
string lower = assetFolderPath.ToLower();
if (!lower.StartsWith("assets/") && !lower.StartsWith("packages/"))
assetFolderPath = "Assets/" + assetFolderPath;
assetFolderPath = assetFolderPath.TrimEnd('/') + "/";
IEnumerable<string> strings = ((IEnumerable<string>)AssetDatabase.GetAllAssetPaths()).Where<string>(
(Func<string, bool>)(x =>
{
if (includeSubDirectories)
return x.StartsWith(assetFolderPath, StringComparison.InvariantCultureIgnoreCase);
return string.Compare(Sirenix.Utilities.PathUtilities.GetDirectoryName(x).Trim('/'),
assetFolderPath.Trim('/'), true) == 0;
}));
menuPath = menuPath ?? "";
menuPath = menuPath.TrimStart('/');
HashSet<OdinMenuItem> result = new HashSet<OdinMenuItem>();
foreach (string str1 in strings)
{
var assetImporter = AssetImporter.GetAtPath(str1);
if (assetImporter != null && type.IsInstanceOfType(assetImporter))
{
string withoutExtension = Path.GetFileNameWithoutExtension(str1);
string path = menuPath;
if (!flattenSubDirectories)
{
string str2 =
(Sirenix.Utilities.PathUtilities.GetDirectoryName(str1).TrimEnd('/') + "/").Substring(
assetFolderPath.Length);
if (str2.Length != 0)
path = path.Trim('/') + "/" + str2;
}
path = path.Trim('/') + "/" + withoutExtension;
string name;
SplitMenuPath(path, out path, out name);
tree.AddMenuItemAtPath((ICollection<OdinMenuItem>)result, path,
new OdinMenuItem(tree, name, (object)@assetImporter));
}
}
return (IEnumerable<OdinMenuItem>)result;
}
private static void SplitMenuPath(string menuPath, out string path, out string name)
{
menuPath = menuPath.Trim('/');
int length = menuPath.LastIndexOf('/');
if (length == -1)
{
path = "";
name = menuPath;
}
else
{
path = menuPath.Substring(0, length);
name = menuPath.Substring(length + 1);
}
}
}
}
#endif

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d4a43b80dfd64b4fab8567212040a549
timeCreated: 1683359884

View File

@@ -0,0 +1,37 @@
#if UNITY_EDITOR
using Sirenix.Serialization;
using UnityEngine;
namespace YIUIFramework.Editor
{
/// <summary>
/// odin 序列化文件存储 适用于大数据
/// </summary>
public static class OdinSerializationUtility
{
public static void Save<T>(T data, string path, DataFormat dataFormat = DataFormat.JSON)
{
var bytes = SerializationUtility.SerializeValue(data, dataFormat);
EditorHelper.WriteAllBytes(path, bytes);
}
public static T Load<T>(string path, DataFormat dataFormat = DataFormat.JSON)
{
var bytes = EditorHelper.ReadAllBytes(path);
if (bytes == null)
{
return default;
}
var data = SerializationUtility.DeserializeValue<T>(bytes, dataFormat);
if (data == null)
{
Debug.LogError($"反序列化错误 {path}");
return default;
}
return data;
}
}
}
#endif

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c99122695d00479b966c46a96e0d7e66
timeCreated: 1683531278