TEngine 6

This commit is contained in:
Alex-Rachel
2025-03-07 23:09:46 +08:00
parent aad8ff3ee5
commit 551727687f
1988 changed files with 46223 additions and 94880 deletions

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 07a483743a0f68e4cb55a38570d1b7cd
guid: 73ef838ec60c36249ba05eaa3c96273e
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using YooAsset.Editor;
[DisplayName("定位地址: 文件名.智能尾缀")]
public class AddressByFileNameAndExt : IAddressRule
{
public string GetAssetAddress(AddressRuleData data)
{
var ext = Path.GetExtension(data.AssetPath);
if (ext == ".asset")
{
var a = UnityEditor.AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(data.AssetPath);
if (a == null) return ".errortype";
var type = a.GetType();
var dt = Path.GetFileNameWithoutExtension(data.AssetPath);
return dt + $".{type.Name.ToLowerInvariant()}";
}
return Path.GetFileName(data.AssetPath);
}
}

View File

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

View File

@@ -9,8 +9,8 @@ namespace YooAsset.Editor
public class PackageComparatorWindow : EditorWindow
{
static PackageComparatorWindow _thisInstance;
[MenuItem("YooAsset/Extension/补丁包比对工具", false, 102)]
[MenuItem("Tools/补丁包比对工具", false, 102)]
static void ShowWindow()
{
if (_thisInstance == null)

View File

@@ -8,7 +8,7 @@ namespace YooAsset.Editor
{
static PackageImporterWindow _thisInstance;
[MenuItem("YooAsset/Extension/补丁包导入工具", false, 101)]
[MenuItem("Tools/补丁包导入工具", false, 101)]
static void ShowWindow()
{
if (_thisInstance == null)
@@ -29,9 +29,8 @@ namespace YooAsset.Editor
if (GUILayout.Button("选择补丁包", GUILayout.MaxWidth(150)))
{
string resultPath = EditorUtility.OpenFilePanel("Find", "Assets/", "bytes");
if (string.IsNullOrEmpty(resultPath))
return;
_manifestPath = resultPath;
if (!string.IsNullOrEmpty(resultPath))
_manifestPath = resultPath;
}
EditorGUILayout.LabelField(_manifestPath);
EditorGUILayout.EndHorizontal();

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 93f24a30c5726804b989f2519943af15
guid: dcb9955c15609744a9666bd76f6af3d9
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: a6f458efe3baabc478ef3b050d5fa721
guid: ab74d4ff4a2805147883de70a1559a0a
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -11,8 +11,10 @@ using UnityEditor;
public class ShaderVariantCollectionManifest
{
[Serializable]
public class ShaderVariantElement
public class ShaderVariantElement : IComparable<ShaderVariantElement>
{
public string SortValue { private set; get; }
/// <summary>
/// Pass type to use in this variant.
/// </summary>
@@ -22,11 +24,31 @@ public class ShaderVariantCollectionManifest
/// Array of shader keywords to use in this variant.
/// </summary>
public string[] Keywords;
public void MakeSortValue()
{
string combineKeyword = string.Empty;
for (int i = 0; i < Keywords.Length; i++)
{
if (i == 0)
combineKeyword = Keywords[0];
else
combineKeyword = $"{combineKeyword}+{Keywords[0]}";
}
SortValue = $"{PassType}+{combineKeyword}";
}
public int CompareTo(ShaderVariantElement other)
{
return SortValue.CompareTo(other.SortValue);
}
}
[Serializable]
public class ShaderVariantInfo : IComparable<ShaderVariantInfo>
{
public string SortValue { private set; get; }
/// <summary>
/// 着色器资源路径.
/// </summary>
@@ -47,11 +69,13 @@ public class ShaderVariantCollectionManifest
/// </summary>
public List<ShaderVariantElement> ShaderVariantElements = new List<ShaderVariantElement>(1000);
public void MakeSortValue()
{
SortValue = AssetPath + "+" + ShaderName;
}
public int CompareTo(ShaderVariantInfo other)
{
string thisStr = AssetPath + "+" +ShaderName;
string otherStr = other.AssetPath + "+" + other.ShaderName;
return thisStr.CompareTo(otherStr);
return SortValue.CompareTo(other.SortValue);
}
}
@@ -76,10 +100,15 @@ public class ShaderVariantCollectionManifest
/// </summary>
public void AddShaderVariant(string assetPath, string shaderName, PassType passType, string[] keywords)
{
// 排序Keyword列表
List<string> temper = new List<string>(keywords);
temper.Sort();
var info = GetOrCreateShaderVariantInfo(assetPath, shaderName);
ShaderVariantElement element = new ShaderVariantElement();
element.PassType = passType;
element.Keywords = keywords;
element.Keywords = temper.ToArray();
element.MakeSortValue();
info.ShaderVariantElements.Add(element);
info.ShaderVariantCount++;
}
@@ -91,6 +120,7 @@ public class ShaderVariantCollectionManifest
ShaderVariantInfo newInfo = new ShaderVariantInfo();
newInfo.AssetPath = assetPath;
newInfo.ShaderName = shaderName;
newInfo.MakeSortValue();
ShaderVariantInfos.Add(newInfo);
return newInfo;
}
@@ -150,6 +180,11 @@ public class ShaderVariantCollectionManifest
// 重新排序
manifest.ShaderVariantInfos.Sort();
foreach (var shaderVariantInfo in manifest.ShaderVariantInfos)
{
shaderVariantInfo.ShaderVariantElements.Sort();
}
return manifest;
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 53dee37cbabc2de478e46c9090c1f685
guid: 97098b04691f5c046ac4829f1d72f425
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -7,7 +7,6 @@ using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
using YooAsset.Editor;
using Debug = UnityEngine.Debug;
public static class ShaderVariantCollector
{
@@ -21,8 +20,8 @@ public static class ShaderVariantCollector
WaitingDone,
}
private const float WaitMilliseconds = 1000f;
private const float SleepMilliseconds = 2000f;
private const float WaitMilliseconds = 3000f;
private const float SleepMilliseconds = 3000f;
private static string _savePath;
private static string _packageName;
private static int _processMaxNum;
@@ -127,7 +126,7 @@ public static class ShaderVariantCollector
ShaderVariantCollectionHelper.SaveCurrentShaderVariantCollection(_savePath);
CreateManifest();
Debug.Log($"搜集SVC完毕");
UnityEngine.Debug.Log($"搜集SVC完毕");
EditorApplication.update -= EditorUpdate;
_completedCallback?.Invoke();
}
@@ -139,39 +138,35 @@ public static class ShaderVariantCollector
}
private static List<string> GetAllMaterials()
{
int progressValue = 0;
List<string> allAssets = new List<string>(1000);
// 获取所有打包的资源
CollectResult collectResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(EBuildMode.DryRunBuild, _packageName);
foreach (var assetInfo in collectResult.CollectAssets)
{
string[] depends = AssetDatabase.GetDependencies(assetInfo.AssetInfo.AssetPath, true);
foreach (var dependAsset in depends)
{
if (allAssets.Contains(dependAsset) == false)
allAssets.Add(dependAsset);
}
EditorTools.DisplayProgressBar("获取所有打包资源", ++progressValue, collectResult.CollectAssets.Count);
}
EditorTools.ClearProgressBar();
CollectResult collectResult = AssetBundleCollectorSettingData.Setting.BeginCollect(_packageName, false, false);
// 搜集所有材质球
progressValue = 0;
List<string> allMaterial = new List<string>(1000);
foreach (var assetPath in allAssets)
int progressValue = 0;
HashSet<string> result = new HashSet<string>();
foreach (var collectAssetInfo in collectResult.CollectAssets)
{
System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
if (assetType == typeof(UnityEngine.Material))
if (collectAssetInfo.AssetInfo.AssetType == typeof(UnityEngine.Material))
{
allMaterial.Add(assetPath);
string assetPath = collectAssetInfo.AssetInfo.AssetPath;
if (result.Contains(assetPath) == false)
result.Add(assetPath);
}
EditorTools.DisplayProgressBar("搜集所有材质球", ++progressValue, allAssets.Count);
foreach(var dependAssetInfo in collectAssetInfo.DependAssets)
{
if (dependAssetInfo.AssetType == typeof(UnityEngine.Material))
{
string assetPath = dependAssetInfo.AssetPath;
if (result.Contains(assetPath) == false)
result.Add(assetPath);
}
}
EditorTools.DisplayProgressBar("搜集所有材质球", ++progressValue, collectResult.CollectAssets.Count);
}
EditorTools.ClearProgressBar();
// 返回结果
return allMaterial;
return result.ToList();
}
private static void CollectVariants(List<string> materials)
{

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: dec5efa58db0c464b86179a0f02cb772
guid: 21b4cc6bf4c0c064d8e2687024e24c86
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: ae6792b0c0b08b3439ab2a9f0362a978
guid: 44454e58a49818040a1aef5799e71b30
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -10,7 +10,7 @@ using YooAsset.Editor;
public class ShaderVariantCollectorWindow : EditorWindow
{
[MenuItem("YooAsset/Extension/着色器变种收集器", false, 100)]
[MenuItem("Tools/着色器变种收集器", false, 100)]
public static void OpenWindow()
{
ShaderVariantCollectorWindow window = GetWindow<ShaderVariantCollectorWindow>("着色器变种收集工具", true);

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: ca3c1c79341e2d24699040948814419e
guid: 70401cc80b9807e46bd8283e01b4302f
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: c740a242d199afb4589223ed405e2074
guid: 9bff4878063eaf04dab8713e1e662ac5
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}