mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
Compare commits
3 Commits
TEngine6.1
...
Unity6000
Author | SHA1 | Date | |
---|---|---|---|
![]() |
745efad95a | ||
![]() |
dc27547eeb | ||
![]() |
780766e2f0 |
@@ -22,3 +22,6 @@ dotnet "${LUBAN_DLL}" \
|
||||
-x code.lineEnding=crlf \
|
||||
-x outputCodeDir="${CODE_OUTPATH}" \
|
||||
-x outputDataDir="${DATA_OUTPATH}"
|
||||
|
||||
echo "操作完成,按任意键退出..."
|
||||
read -k1
|
||||
|
@@ -23,3 +23,6 @@ dotnet "${LUBAN_DLL}" \
|
||||
-x code.lineEnding=crlf \
|
||||
-x outputCodeDir="${CODE_OUTPATH}" \
|
||||
-x outputDataDir="${DATA_OUTPATH}"
|
||||
|
||||
echo "操作完成,按任意键退出..."
|
||||
read -k1
|
||||
|
@@ -17,3 +17,6 @@ dotnet "${LUBAN_DLL}" \
|
||||
-x code.lineEnding=crlf \
|
||||
-x outputCodeDir="${CODE_OUTPATH}" \
|
||||
-x outputDataDir="${DATA_OUTPATH}"
|
||||
|
||||
echo "操作完成,按任意键退出..."
|
||||
read -k1
|
||||
|
@@ -23,14 +23,12 @@
|
||||
<a style="text-decoration:none">
|
||||
<img src="https://img.shields.io/github/languages/top/ALEXTANGXIAO/TEngine" alt="topLanguage" />
|
||||
</a>
|
||||
<a href="https://deepwiki.com/Alex-Rachel/TEngine" style="text-decoration:none">
|
||||
<img src="https://deepwiki.com/badge.svg" alt="DeepWiki" />
|
||||
</a>
|
||||
<br>
|
||||
|
||||
<br>
|
||||
</p>
|
||||
|
||||
|
||||
# <strong>TEngine
|
||||
|
||||
#### TEngine是一个简单(新手友好开箱即用)且强大的Unity框架全平台解决方案,对于需要一套上手快、文档清晰、高性能且可拓展性极强的商业级解决方案的开发者或者团队来说是一个很好的选择。
|
||||
@@ -102,8 +100,6 @@ TEngine
|
||||
|
||||
#### <a href="https://github.com/ALEXTANGXIAO/GameNetty"><strong>GameNetty</strong></a> - GameNetty是一套源于ETServer,首次拆分最新的ET8.1的前后端解决方案(包),客户端最精简大约750k,完美做成包的形式,几乎零成本 无侵入的嵌入进你的框架。
|
||||
|
||||
#### <a href="https://github.com/Herta-Space-Station/FixedPoint"><strong>FixedPoint</strong></a> - 性能极限的定点数学库FixedPoint。
|
||||
|
||||
|
||||
## <strong>Buy me a 奶茶.
|
||||
|
||||
|
@@ -1,174 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TEngine.Editor
|
||||
{
|
||||
internal sealed class AssetTreeView : TreeView
|
||||
{
|
||||
private const float K_ICON_WIDTH = 18f;
|
||||
private const float K_ROW_HEIGHTS = 20f;
|
||||
private readonly GUIStyle _stateGuiStyle = new GUIStyle { richText = true, alignment = TextAnchor.MiddleCenter };
|
||||
public AssetViewItem assetRoot;
|
||||
|
||||
public AssetTreeView(TreeViewState state, MultiColumnHeader multicolumnHeader) : base(state, multicolumnHeader)
|
||||
{
|
||||
rowHeight = K_ROW_HEIGHTS;
|
||||
columnIndexForTreeFoldouts = 0;
|
||||
showAlternatingRowBackgrounds = true;
|
||||
showBorder = false;
|
||||
customFoldoutYOffset = (K_ROW_HEIGHTS - EditorGUIUtility.singleLineHeight) * 0.5f;
|
||||
extraSpaceBeforeIconAndLabel = K_ICON_WIDTH;
|
||||
}
|
||||
|
||||
protected override void DoubleClickedItem(int id)
|
||||
{
|
||||
AssetViewItem item = (AssetViewItem)FindItem(id, rootItem);
|
||||
if (item != null)
|
||||
{
|
||||
Object assetObject = AssetDatabase.LoadAssetAtPath(item.data.path, typeof(Object));
|
||||
EditorUtility.FocusProjectWindow();
|
||||
Selection.activeObject = assetObject;
|
||||
EditorGUIUtility.PingObject(assetObject);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ExpandedStateChanged() => SortExpandItem();
|
||||
|
||||
public void SortExpandItem()
|
||||
{
|
||||
if (SortHelper.CurSortType == SortType.None) return;
|
||||
IList<int> expandItemList = GetExpanded();
|
||||
foreach (int i in expandItemList)
|
||||
{
|
||||
AssetViewItem item = (AssetViewItem)FindItem(i, rootItem);
|
||||
SortHelper.SortChild(item.data);
|
||||
}
|
||||
|
||||
ResourceReferenceInfo curWindow = EditorWindow.GetWindow<ResourceReferenceInfo>();
|
||||
curWindow.needUpdateAssetTree = true;
|
||||
}
|
||||
|
||||
public static MultiColumnHeaderState CreateDefaultMultiColumnHeaderState(float treeViewWidth, bool isDepend)
|
||||
{
|
||||
List<MultiColumnHeaderState.Column> columns = new List<MultiColumnHeaderState.Column>
|
||||
{
|
||||
new MultiColumnHeaderState.Column
|
||||
{
|
||||
headerContent = new GUIContent("名称"),
|
||||
headerTextAlignment = TextAlignment.Center,
|
||||
sortedAscending = false,
|
||||
width = 200,
|
||||
minWidth = 60,
|
||||
autoResize = false,
|
||||
allowToggleVisibility = false,
|
||||
canSort = true,
|
||||
sortingArrowAlignment = TextAlignment.Center
|
||||
},
|
||||
new MultiColumnHeaderState.Column
|
||||
{
|
||||
headerContent = new GUIContent("路径"),
|
||||
headerTextAlignment = TextAlignment.Center,
|
||||
sortedAscending = false,
|
||||
width = 360,
|
||||
minWidth = 60,
|
||||
autoResize = false,
|
||||
allowToggleVisibility = false,
|
||||
canSort = true,
|
||||
sortingArrowAlignment = TextAlignment.Center
|
||||
},
|
||||
new MultiColumnHeaderState.Column
|
||||
{
|
||||
headerContent = new GUIContent("状态"),
|
||||
headerTextAlignment = TextAlignment.Center,
|
||||
sortedAscending = false,
|
||||
width = 60,
|
||||
minWidth = 60,
|
||||
autoResize = false,
|
||||
allowToggleVisibility = true,
|
||||
canSort = false
|
||||
}
|
||||
};
|
||||
if (!isDepend)
|
||||
{
|
||||
columns.Add(new MultiColumnHeaderState.Column
|
||||
{
|
||||
headerContent = new GUIContent("引用数量"),
|
||||
headerTextAlignment = TextAlignment.Center,
|
||||
sortedAscending = false,
|
||||
width = 60,
|
||||
minWidth = 60,
|
||||
autoResize = true,
|
||||
allowToggleVisibility = true,
|
||||
canSort = false
|
||||
});
|
||||
}
|
||||
|
||||
MultiColumnHeaderState state = new MultiColumnHeaderState(columns.ToArray());
|
||||
return state;
|
||||
}
|
||||
|
||||
protected override TreeViewItem BuildRoot() => assetRoot;
|
||||
|
||||
protected override void RowGUI(RowGUIArgs args)
|
||||
{
|
||||
AssetViewItem item = (AssetViewItem)args.item;
|
||||
for (int i = 0; i < args.GetNumVisibleColumns(); ++i)
|
||||
CellGUI(args.GetCellRect(i), item, (MyColumns)args.GetColumn(i), ref args);
|
||||
}
|
||||
|
||||
private void CellGUI(Rect cellRect, AssetViewItem item, MyColumns column, ref RowGUIArgs args)
|
||||
{
|
||||
CenterRectUsingSingleLineHeight(ref cellRect);
|
||||
switch (column)
|
||||
{
|
||||
case MyColumns.Name:
|
||||
Rect iconRect = cellRect;
|
||||
iconRect.x += GetContentIndent(item);
|
||||
iconRect.width = K_ICON_WIDTH;
|
||||
if (iconRect.x < cellRect.xMax)
|
||||
{
|
||||
Texture2D icon = GetIcon(item.data.path);
|
||||
if (icon != null)
|
||||
GUI.DrawTexture(iconRect, icon, ScaleMode.ScaleToFit);
|
||||
}
|
||||
|
||||
args.rowRect = cellRect;
|
||||
base.RowGUI(args);
|
||||
break;
|
||||
case MyColumns.Path:
|
||||
GUI.Label(cellRect, item.data.path);
|
||||
break;
|
||||
case MyColumns.State:
|
||||
GUI.Label(cellRect, ReferenceFinderData.GetInfoByState(item.data.state), _stateGuiStyle);
|
||||
break;
|
||||
case MyColumns.RefCount:
|
||||
GUI.Label(cellRect, ResourceReferenceInfo.Data.GetRefCount(item.data, (item.parent as AssetViewItem)?.data), _stateGuiStyle);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private Texture2D GetIcon(string path)
|
||||
{
|
||||
Object obj = AssetDatabase.LoadAssetAtPath(path, typeof(Object));
|
||||
if (obj)
|
||||
{
|
||||
Texture2D icon = AssetPreview.GetMiniThumbnail(obj);
|
||||
if (!icon)
|
||||
icon = AssetPreview.GetMiniTypeThumbnail(obj.GetType());
|
||||
return icon;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private enum MyColumns
|
||||
{
|
||||
Name,
|
||||
Path,
|
||||
State,
|
||||
RefCount
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dd079ed03e211ca4698770fc925dcf0a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,9 +0,0 @@
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
|
||||
namespace TEngine.Editor
|
||||
{
|
||||
internal sealed class AssetViewItem : TreeViewItem
|
||||
{
|
||||
public ReferenceFinderData.AssetDescription data;
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 62d7d07cebb3f9b4998845a11799e12c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,34 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
|
||||
namespace TEngine.Editor
|
||||
{
|
||||
internal sealed class ClickColumn : MultiColumnHeader
|
||||
{
|
||||
public delegate void SortInColumn();
|
||||
|
||||
public static Dictionary<int, SortInColumn> SortWithIndex = new Dictionary<int, SortInColumn>
|
||||
{
|
||||
{ 0, SortByName },
|
||||
{ 1, SortByPath }
|
||||
};
|
||||
|
||||
public ClickColumn(MultiColumnHeaderState state) : base(state) => canSort = true;
|
||||
|
||||
protected override void ColumnHeaderClicked(MultiColumnHeaderState.Column column, int columnIndex)
|
||||
{
|
||||
base.ColumnHeaderClicked(column, columnIndex);
|
||||
if (SortWithIndex.ContainsKey(columnIndex))
|
||||
{
|
||||
SortWithIndex[columnIndex].Invoke();
|
||||
ResourceReferenceInfo curWindow = EditorWindow.GetWindow<ResourceReferenceInfo>();
|
||||
curWindow.mAssetTreeView.SortExpandItem();
|
||||
}
|
||||
}
|
||||
|
||||
public static void SortByName() => SortHelper.SortByName();
|
||||
|
||||
public static void SortByPath() => SortHelper.SortByPath();
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4047444d841109d46b15817bbe887281
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,29 +0,0 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TEngine.Editor
|
||||
{
|
||||
internal sealed class DragAreaGetObject
|
||||
{
|
||||
public static Object[] GetObjects(string meg = null)
|
||||
{
|
||||
Event aEvent = Event.current;
|
||||
GUI.contentColor = Color.white;
|
||||
if (aEvent.type is EventType.DragUpdated or EventType.DragPerform)
|
||||
{
|
||||
DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
|
||||
bool needReturn = false;
|
||||
if (aEvent.type == EventType.DragPerform)
|
||||
{
|
||||
DragAndDrop.AcceptDrag();
|
||||
needReturn = true;
|
||||
}
|
||||
|
||||
Event.current.Use();
|
||||
if (needReturn) return DragAndDrop.objectReferences;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 59773aa6a03462c488a3e18ea3de8660
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,9 +0,0 @@
|
||||
namespace TEngine.Editor
|
||||
{
|
||||
internal sealed class ListInfo
|
||||
{
|
||||
public int Count;
|
||||
public string Name;
|
||||
public string Type;
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 36df700a4102b0c4db5f7ec3c485cf0c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,417 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace TEngine.Editor
|
||||
{
|
||||
internal sealed class ReferenceFinderData
|
||||
{
|
||||
public enum AssetState : byte
|
||||
{
|
||||
Normal,
|
||||
Changed,
|
||||
Missing,
|
||||
Invalid
|
||||
}
|
||||
|
||||
private const string CachePath = "Library/ReferenceFinderCache";
|
||||
public const int MinThreadCount = 8;
|
||||
private const int SingleThreadReadCount = 100;
|
||||
private static readonly int ThreadCount = Math.Max(MinThreadCount, Environment.ProcessorCount);
|
||||
private static string _basePath;
|
||||
|
||||
private static readonly HashSet<string> FileExtension = new HashSet<string>
|
||||
{
|
||||
".prefab",
|
||||
".unity",
|
||||
".mat",
|
||||
".asset",
|
||||
".anim",
|
||||
".controller"
|
||||
};
|
||||
|
||||
private static readonly Regex GuidRegex = new Regex("guid: ([a-z0-9]{32})", RegexOptions.Singleline | RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
private readonly Dictionary<(AssetDescription, AssetDescription), int> _dictCache = new Dictionary<(AssetDescription, AssetDescription), int>();
|
||||
private readonly List<Dictionary<string, AssetDescription>> _threadAssetDict = new List<Dictionary<string, AssetDescription>>();
|
||||
private readonly List<Thread> _threadList = new List<Thread>();
|
||||
private int _curReadAssetCount;
|
||||
private int _totalCount;
|
||||
public string[] allAssets;
|
||||
public Dictionary<string, AssetDescription> assetDict = new Dictionary<string, AssetDescription>();
|
||||
|
||||
public void CollectDependenciesInfo()
|
||||
{
|
||||
try
|
||||
{
|
||||
_basePath = Application.dataPath.Replace("/Assets", "");
|
||||
ReadFromCache();
|
||||
allAssets = AssetDatabase.GetAllAssetPaths();
|
||||
_totalCount = allAssets.Length;
|
||||
_threadList.Clear();
|
||||
_curReadAssetCount = 0;
|
||||
foreach (Dictionary<string, AssetDescription> i in _threadAssetDict)
|
||||
i.Clear();
|
||||
_threadAssetDict.Clear();
|
||||
for (int i = 0; i < ThreadCount; i++) _threadAssetDict.Add(new Dictionary<string, AssetDescription>());
|
||||
bool allThreadFinish = false;
|
||||
for (int i = 0; i < ThreadCount; i++)
|
||||
{
|
||||
ThreadStart method = ReadAssetInfo;
|
||||
Thread readThread = new Thread(method);
|
||||
_threadList.Add(readThread);
|
||||
readThread.Start();
|
||||
}
|
||||
|
||||
while (!allThreadFinish)
|
||||
{
|
||||
if (_curReadAssetCount % 500 == 0 &&
|
||||
EditorUtility.DisplayCancelableProgressBar("Updating", $"Handle {_curReadAssetCount}", (float)_curReadAssetCount / _totalCount))
|
||||
{
|
||||
EditorUtility.ClearProgressBar();
|
||||
foreach (Thread i in _threadList)
|
||||
i.Abort();
|
||||
return;
|
||||
}
|
||||
|
||||
allThreadFinish = true;
|
||||
foreach (Thread i in _threadList)
|
||||
{
|
||||
if (i.IsAlive)
|
||||
{
|
||||
allThreadFinish = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Dictionary<string, AssetDescription> dict in _threadAssetDict)
|
||||
{
|
||||
foreach (KeyValuePair<string, AssetDescription> j in dict)
|
||||
assetDict[j.Key] = j.Value;
|
||||
}
|
||||
|
||||
EditorUtility.DisplayCancelableProgressBar("Updating", "Write cache", 1f);
|
||||
WriteToChache();
|
||||
EditorUtility.DisplayCancelableProgressBar("Updating", "Generate reference data", 1f);
|
||||
UpdateResourceReferenceInfo();
|
||||
EditorUtility.ClearProgressBar();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError(e);
|
||||
EditorUtility.ClearProgressBar();
|
||||
}
|
||||
}
|
||||
|
||||
public void ReadAssetInfo()
|
||||
{
|
||||
int index = Thread.CurrentThread.ManagedThreadId % ThreadCount;
|
||||
int intervalLength = _totalCount / ThreadCount;
|
||||
int start = intervalLength * index;
|
||||
int end = start + intervalLength;
|
||||
if (_totalCount - end < intervalLength)
|
||||
end = _totalCount;
|
||||
int readAssetCount = 0;
|
||||
for (int i = start; i < end; i++)
|
||||
{
|
||||
if (readAssetCount % SingleThreadReadCount == 0)
|
||||
{
|
||||
_curReadAssetCount += readAssetCount;
|
||||
readAssetCount = 0;
|
||||
}
|
||||
|
||||
GetAsset(_basePath, allAssets[i]);
|
||||
readAssetCount++;
|
||||
}
|
||||
}
|
||||
|
||||
public void GetAsset(string dataPath, string assetPath)
|
||||
{
|
||||
string extLowerStr = Path.GetExtension(assetPath).ToLower();
|
||||
bool needReadFile = FileExtension.Contains(extLowerStr);
|
||||
string fileName = $"{dataPath}/{assetPath}";
|
||||
string metaFile = $"{dataPath}/{assetPath}.meta";
|
||||
if (File.Exists(fileName) && File.Exists(metaFile))
|
||||
{
|
||||
string metaText = File.ReadAllText(metaFile, Encoding.UTF8);
|
||||
MatchCollection matchRs = GuidRegex.Matches(metaText);
|
||||
string selfGuid = matchRs[0].Groups[1].Value.ToLower();
|
||||
string lastModifyTime = File.GetLastWriteTime(fileName).ToString(CultureInfo.InvariantCulture);
|
||||
MatchCollection guids = null;
|
||||
List<string> depend = new List<string>();
|
||||
if (needReadFile)
|
||||
{
|
||||
string fileStr = File.ReadAllText(fileName, Encoding.UTF8);
|
||||
guids = GuidRegex.Matches(fileStr);
|
||||
}
|
||||
|
||||
int curListIndex = Thread.CurrentThread.ManagedThreadId % ThreadCount;
|
||||
Dictionary<string, AssetDescription> curDict = _threadAssetDict[curListIndex];
|
||||
if (!curDict.ContainsKey(selfGuid) || curDict[selfGuid].assetDependencyHashString != lastModifyTime)
|
||||
{
|
||||
if (guids != null)
|
||||
{
|
||||
for (int index = 0; index < guids.Count; ++index)
|
||||
{
|
||||
Match i = guids[index];
|
||||
depend.Add(i.Groups[1].Value.ToLower());
|
||||
}
|
||||
}
|
||||
|
||||
AssetDescription ad = new AssetDescription
|
||||
{
|
||||
name = Path.GetFileNameWithoutExtension(assetPath),
|
||||
path = assetPath,
|
||||
assetDependencyHashString = lastModifyTime,
|
||||
dependencies = depend
|
||||
};
|
||||
|
||||
if (_threadAssetDict[curListIndex].ContainsKey(selfGuid))
|
||||
_threadAssetDict[curListIndex][selfGuid] = ad;
|
||||
else
|
||||
_threadAssetDict[curListIndex].Add(selfGuid, ad);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateResourceReferenceInfo()
|
||||
{
|
||||
foreach (KeyValuePair<string, AssetDescription> asset in assetDict)
|
||||
{
|
||||
foreach (string assetGuid in asset.Value.dependencies)
|
||||
{
|
||||
if (assetDict.ContainsKey(assetGuid))
|
||||
assetDict[assetGuid].references.Add(asset.Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool ReadFromCache()
|
||||
{
|
||||
assetDict.Clear();
|
||||
ClearCache();
|
||||
if (File.Exists(CachePath))
|
||||
{
|
||||
List<string> serializedGuid;
|
||||
List<string> serializedDependencyHash;
|
||||
List<int[]> serializedDenpendencies;
|
||||
using (FileStream fs = File.OpenRead(CachePath))
|
||||
{
|
||||
BinaryFormatter bf = new BinaryFormatter();
|
||||
if (EditorUtility.DisplayCancelableProgressBar("Import Cache", "Reading Cache", 0))
|
||||
{
|
||||
EditorUtility.ClearProgressBar();
|
||||
return false;
|
||||
}
|
||||
|
||||
serializedGuid = (List<string>)bf.Deserialize(fs);
|
||||
serializedDependencyHash = (List<string>)bf.Deserialize(fs);
|
||||
serializedDenpendencies = (List<int[]>)bf.Deserialize(fs);
|
||||
EditorUtility.ClearProgressBar();
|
||||
}
|
||||
|
||||
for (int i = 0; i < serializedGuid.Count; ++i)
|
||||
{
|
||||
string path = AssetDatabase.GUIDToAssetPath(serializedGuid[i]);
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
AssetDescription ad = new AssetDescription
|
||||
{
|
||||
name = Path.GetFileNameWithoutExtension(path),
|
||||
path = path,
|
||||
assetDependencyHashString = serializedDependencyHash[i]
|
||||
};
|
||||
assetDict.Add(serializedGuid[i], ad);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < serializedGuid.Count; ++i)
|
||||
{
|
||||
string guid = serializedGuid[i];
|
||||
if (assetDict.ContainsKey(guid))
|
||||
{
|
||||
List<string> guids = new List<string>();
|
||||
foreach (int index in serializedDenpendencies[i])
|
||||
{
|
||||
string g = serializedGuid[index];
|
||||
if (assetDict.ContainsKey(g))
|
||||
guids.Add(g);
|
||||
}
|
||||
|
||||
assetDict[guid].dependencies = guids;
|
||||
}
|
||||
}
|
||||
|
||||
UpdateResourceReferenceInfo();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void WriteToChache()
|
||||
{
|
||||
if (File.Exists(CachePath))
|
||||
File.Delete(CachePath);
|
||||
List<string> serializedGuid = new List<string>();
|
||||
List<string> serializedDependencyHash = new List<string>();
|
||||
List<int[]> serializedDenpendencies = new List<int[]>();
|
||||
Dictionary<string, int> guidIndex = new Dictionary<string, int>();
|
||||
using FileStream fs = File.OpenWrite(CachePath);
|
||||
foreach (KeyValuePair<string, AssetDescription> pair in assetDict)
|
||||
{
|
||||
guidIndex.Add(pair.Key, guidIndex.Count);
|
||||
serializedGuid.Add(pair.Key);
|
||||
serializedDependencyHash.Add(pair.Value.assetDependencyHashString);
|
||||
}
|
||||
|
||||
foreach (string guid in serializedGuid)
|
||||
{
|
||||
List<int> res = new List<int>();
|
||||
foreach (string i in assetDict[guid].dependencies)
|
||||
{
|
||||
if (guidIndex.TryGetValue(i, out var value))
|
||||
res.Add(value);
|
||||
}
|
||||
|
||||
int[] indexes = res.ToArray();
|
||||
serializedDenpendencies.Add(indexes);
|
||||
}
|
||||
|
||||
BinaryFormatter bf = new BinaryFormatter();
|
||||
bf.Serialize(fs, serializedGuid);
|
||||
bf.Serialize(fs, serializedDependencyHash);
|
||||
bf.Serialize(fs, serializedDenpendencies);
|
||||
}
|
||||
|
||||
public void UpdateAssetState(string guid)
|
||||
{
|
||||
if (assetDict.TryGetValue(guid, out AssetDescription ad) && ad.state != AssetState.Invalid)
|
||||
{
|
||||
if (File.Exists(ad.path))
|
||||
ad.state = ad.assetDependencyHashString != File.GetLastWriteTime(ad.path).ToString(CultureInfo.InvariantCulture) ? AssetState.Changed : AssetState.Normal;
|
||||
else
|
||||
ad.state = AssetState.Missing;
|
||||
}
|
||||
else if (!assetDict.TryGetValue(guid, out ad))
|
||||
{
|
||||
string path = AssetDatabase.GUIDToAssetPath(guid);
|
||||
ad = new AssetDescription
|
||||
{
|
||||
name = Path.GetFileNameWithoutExtension(path),
|
||||
path = path,
|
||||
state = AssetState.Invalid
|
||||
};
|
||||
assetDict.Add(guid, ad);
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetInfoByState(AssetState state)
|
||||
{
|
||||
if (state == AssetState.Changed)
|
||||
return "<color=red>缓存不匹配</color>";
|
||||
if (state == AssetState.Missing)
|
||||
return "<color=red>缓存丢失</color>";
|
||||
if (state == AssetState.Invalid)
|
||||
return "<color=yellow>缓存无效</color>";
|
||||
return "<color=green>缓存正常</color>";
|
||||
}
|
||||
|
||||
private int GetRefCount(string assetGUID, AssetDescription desc, List<string> guidStack)
|
||||
{
|
||||
if (guidStack.Contains(assetGUID))
|
||||
{
|
||||
Debug.Log("有循环引用, 计数可能不准确");
|
||||
return 0;
|
||||
}
|
||||
|
||||
guidStack.Add(assetGUID);
|
||||
int total = 0;
|
||||
if (assetDict.TryGetValue(assetGUID, out AssetDescription value))
|
||||
{
|
||||
if (value.references.Count > 0)
|
||||
{
|
||||
Dictionary<string, int> cachedRefCount = new Dictionary<string, int>();
|
||||
foreach (string refs in value.references)
|
||||
{
|
||||
if (!cachedRefCount.ContainsKey(refs))
|
||||
{
|
||||
int refCount = GetRefCount(refs, value, guidStack);
|
||||
cachedRefCount[refs] = refCount;
|
||||
total += refCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
total = 0;
|
||||
if (desc != null)
|
||||
{
|
||||
string guid = AssetDatabase.AssetPathToGUID(desc.path);
|
||||
foreach (string deps in value.dependencies)
|
||||
{
|
||||
if (guid == deps)
|
||||
total++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
guidStack.RemoveAt(guidStack.Count - 1);
|
||||
return total;
|
||||
}
|
||||
|
||||
public void ClearCache() => _dictCache.Clear();
|
||||
|
||||
public string GetRefCount(AssetDescription desc, AssetDescription parentDesc)
|
||||
{
|
||||
if (_dictCache.TryGetValue((desc, parentDesc), out int total))
|
||||
return total.ToString();
|
||||
string rootGUID = AssetDatabase.AssetPathToGUID(desc.path);
|
||||
List<string> guidInStack = new List<string> { rootGUID };
|
||||
Dictionary<string, int> cachedRefCount = new Dictionary<string, int>();
|
||||
foreach (string refs in desc.references)
|
||||
{
|
||||
if (!cachedRefCount.ContainsKey(refs))
|
||||
{
|
||||
int refCount = GetRefCount(refs, desc, guidInStack);
|
||||
cachedRefCount[refs] = refCount;
|
||||
total += refCount;
|
||||
}
|
||||
}
|
||||
|
||||
if (desc.references.Count == 0 && parentDesc != null)
|
||||
{
|
||||
string guid = AssetDatabase.AssetPathToGUID(desc.path);
|
||||
foreach (string refs in parentDesc.references)
|
||||
{
|
||||
if (refs == guid)
|
||||
total++;
|
||||
}
|
||||
}
|
||||
|
||||
guidInStack.RemoveAt(guidInStack.Count - 1);
|
||||
_dictCache.Add((desc, parentDesc), total);
|
||||
return total.ToString();
|
||||
}
|
||||
|
||||
internal sealed class AssetDescription
|
||||
{
|
||||
public string assetDependencyHashString;
|
||||
public List<string> dependencies = new List<string>();
|
||||
public string name = "";
|
||||
public string path = "";
|
||||
public List<string> references = new List<string>();
|
||||
public AssetState state = AssetState.Normal;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1fd14799f035fc4b817d8e78253548e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,307 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TEngine.Editor
|
||||
{
|
||||
internal sealed class ResourceReferenceInfo : EditorWindow
|
||||
{
|
||||
private const string IS_DEPEND_PREF_KEY = "ReferenceFinderData_IsDepend";
|
||||
public static readonly ReferenceFinderData Data = new ReferenceFinderData();
|
||||
private static bool _initializedData;
|
||||
|
||||
[SerializeField]
|
||||
private TreeViewState _treeViewState;
|
||||
|
||||
public bool needUpdateAssetTree;
|
||||
public bool needUpdateState = true;
|
||||
public List<string> selectedAssetGuid = new List<string>();
|
||||
private readonly HashSet<string> _brotherAssetIsAdd = new HashSet<string>();
|
||||
private readonly HashSet<string> _parentAssetIsAdd = new HashSet<string>();
|
||||
private readonly HashSet<string> _updatedAssetSet = new HashSet<string>();
|
||||
private Dictionary<string, ListInfo> _artInfo = new Dictionary<string, ListInfo>();
|
||||
private bool _initializedGUIStyle;
|
||||
private bool _isDepend;
|
||||
private GUIStyle _toolbarButtonGUIStyle;
|
||||
private GUIStyle _toolbarGUIStyle;
|
||||
public AssetTreeView mAssetTreeView;
|
||||
|
||||
private void OnEnable() => _isDepend = PlayerPrefs.GetInt(IS_DEPEND_PREF_KEY, 0) == 1;
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
UpdateDragAssets();
|
||||
InitGUIStyleIfNeeded();
|
||||
DrawOptionBar();
|
||||
UpdateAssetTree();
|
||||
mAssetTreeView?.OnGUI(new Rect(0, _toolbarGUIStyle.fixedHeight, position.width, position.height - _toolbarGUIStyle.fixedHeight));
|
||||
}
|
||||
|
||||
[MenuItem("TEngine/查找资产引用 _F10", false, 100)]
|
||||
public static void FindRef()
|
||||
{
|
||||
InitDataIfNeeded();
|
||||
OpenWindow();
|
||||
ResourceReferenceInfo window = GetWindow<ResourceReferenceInfo>();
|
||||
window.UpdateSelectedAssets();
|
||||
}
|
||||
|
||||
private static void OpenWindow()
|
||||
{
|
||||
ResourceReferenceInfo window = GetWindow<ResourceReferenceInfo>();
|
||||
window.wantsMouseMove = false;
|
||||
window.titleContent = new GUIContent("查找资产引用");
|
||||
window.Show();
|
||||
window.Focus();
|
||||
SortHelper.Init();
|
||||
}
|
||||
|
||||
private static void InitDataIfNeeded()
|
||||
{
|
||||
if (!_initializedData)
|
||||
{
|
||||
if (!Data.ReadFromCache())
|
||||
Data.CollectDependenciesInfo();
|
||||
_initializedData = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void InitGUIStyleIfNeeded()
|
||||
{
|
||||
if (!_initializedGUIStyle)
|
||||
{
|
||||
_toolbarButtonGUIStyle = new GUIStyle("ToolbarButton");
|
||||
_toolbarGUIStyle = new GUIStyle("Toolbar");
|
||||
_initializedGUIStyle = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSelectedAssets()
|
||||
{
|
||||
_artInfo = new Dictionary<string, ListInfo>();
|
||||
selectedAssetGuid.Clear();
|
||||
foreach (Object obj in Selection.objects)
|
||||
{
|
||||
string path = AssetDatabase.GetAssetPath(obj);
|
||||
if (Directory.Exists(path))
|
||||
{
|
||||
string[] folder = { path };
|
||||
string[] guids = AssetDatabase.FindAssets(null, folder);
|
||||
foreach (string guid in guids)
|
||||
{
|
||||
if (!selectedAssetGuid.Contains(guid) && !Directory.Exists(AssetDatabase.GUIDToAssetPath(guid)))
|
||||
selectedAssetGuid.Add(guid);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string guid = AssetDatabase.AssetPathToGUID(path);
|
||||
selectedAssetGuid.Add(guid);
|
||||
}
|
||||
}
|
||||
|
||||
needUpdateAssetTree = true;
|
||||
}
|
||||
|
||||
private void UpdateDragAssets()
|
||||
{
|
||||
if (mouseOverWindow)
|
||||
{
|
||||
Object[] tempObj = DragAreaGetObject.GetObjects();
|
||||
if (tempObj != null)
|
||||
{
|
||||
InitDataIfNeeded();
|
||||
selectedAssetGuid.Clear();
|
||||
foreach (Object obj in tempObj)
|
||||
{
|
||||
string path = AssetDatabase.GetAssetPath(obj);
|
||||
if (Directory.Exists(path))
|
||||
{
|
||||
string[] folder = { path };
|
||||
string[] guids = AssetDatabase.FindAssets(null, folder);
|
||||
foreach (string guid in guids)
|
||||
{
|
||||
if (!selectedAssetGuid.Contains(guid) && !Directory.Exists(AssetDatabase.GUIDToAssetPath(guid)))
|
||||
selectedAssetGuid.Add(guid);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string guid = AssetDatabase.AssetPathToGUID(path);
|
||||
selectedAssetGuid.Add(guid);
|
||||
}
|
||||
}
|
||||
|
||||
needUpdateAssetTree = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateAssetTree()
|
||||
{
|
||||
if (needUpdateAssetTree && selectedAssetGuid.Count != 0)
|
||||
{
|
||||
AssetViewItem root = SelectedAssetGuidToRootItem(selectedAssetGuid);
|
||||
if (mAssetTreeView == null)
|
||||
{
|
||||
if (_treeViewState == null)
|
||||
_treeViewState = new TreeViewState();
|
||||
MultiColumnHeaderState headerState = AssetTreeView.CreateDefaultMultiColumnHeaderState(position.width, _isDepend);
|
||||
ClickColumn multiColumnHeader = new ClickColumn(headerState);
|
||||
mAssetTreeView = new AssetTreeView(_treeViewState, multiColumnHeader);
|
||||
}
|
||||
else
|
||||
{
|
||||
MultiColumnHeaderState headerState = AssetTreeView.CreateDefaultMultiColumnHeaderState(position.width, _isDepend);
|
||||
ClickColumn multiColumnHeader = new ClickColumn(headerState);
|
||||
mAssetTreeView.multiColumnHeader = multiColumnHeader;
|
||||
}
|
||||
|
||||
mAssetTreeView.assetRoot = root;
|
||||
mAssetTreeView.Reload();
|
||||
needUpdateAssetTree = false;
|
||||
int totalPrefab = 0;
|
||||
int totalMat = 0;
|
||||
string prefabName = "";
|
||||
string matName = "";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (_artInfo.Count > 0)
|
||||
{
|
||||
foreach (KeyValuePair<string, ListInfo> kv in _artInfo)
|
||||
{
|
||||
if (kv.Value.Type == "prefab")
|
||||
{
|
||||
totalPrefab += kv.Value.Count;
|
||||
prefabName += kv.Value.Name + "<--->";
|
||||
}
|
||||
|
||||
if (kv.Value.Type == "mat")
|
||||
{
|
||||
totalMat += kv.Value.Count;
|
||||
matName += kv.Value.Name + "<--->";
|
||||
}
|
||||
|
||||
string tempInfo = $"name <color=green>[{kv.Key}]</color>, type: <color=orange>[{kv.Value.Type}]</color>, count: <color=red>[{kv.Value.Count}]</color>";
|
||||
sb.AppendLine(tempInfo);
|
||||
}
|
||||
}
|
||||
|
||||
if (totalPrefab > 0)
|
||||
sb.Insert(0, $"预制体总数 <color=red>[{totalPrefab}]</color> 预制体详情 <color=green>[{prefabName}]</color> \r\n");
|
||||
if (totalMat > 0)
|
||||
sb.Insert(0, $"材质总数 <color=red>[{totalMat}]</color> 材质详情 <color=green>[{matName}]</color> \r\n");
|
||||
string str = sb.ToString();
|
||||
if (!string.IsNullOrEmpty(str))
|
||||
Debug.Log(str);
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawOptionBar()
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal(_toolbarGUIStyle);
|
||||
if (GUILayout.Button("点击更新本地缓存", _toolbarButtonGUIStyle))
|
||||
{
|
||||
Data.CollectDependenciesInfo();
|
||||
needUpdateAssetTree = true;
|
||||
GUIUtility.ExitGUI();
|
||||
}
|
||||
|
||||
bool preIsDepend = _isDepend;
|
||||
_isDepend = GUILayout.Toggle(_isDepend, _isDepend ? "依赖模式" : "引用模式", _toolbarButtonGUIStyle, GUILayout.Width(100));
|
||||
if (preIsDepend != _isDepend)
|
||||
OnModelSelect();
|
||||
if (GUILayout.Button("展开", _toolbarButtonGUIStyle))
|
||||
mAssetTreeView?.ExpandAll();
|
||||
if (GUILayout.Button("折叠", _toolbarButtonGUIStyle))
|
||||
mAssetTreeView?.CollapseAll();
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
private void OnModelSelect()
|
||||
{
|
||||
needUpdateAssetTree = true;
|
||||
PlayerPrefs.SetInt(IS_DEPEND_PREF_KEY, _isDepend ? 1 : 0);
|
||||
UpdateAssetTree();
|
||||
}
|
||||
|
||||
private AssetViewItem SelectedAssetGuidToRootItem(List<string> inputSelectedAssetGuid)
|
||||
{
|
||||
_updatedAssetSet.Clear();
|
||||
_parentAssetIsAdd.Clear();
|
||||
_brotherAssetIsAdd.Clear();
|
||||
int elementCount = 0;
|
||||
AssetViewItem root = new AssetViewItem { id = elementCount, depth = -1, displayName = "Root", data = null };
|
||||
const int depth = 0;
|
||||
foreach (string childGuid in inputSelectedAssetGuid)
|
||||
{
|
||||
AssetViewItem rs = CreateTree(childGuid, ref elementCount, depth);
|
||||
root.AddChild(rs);
|
||||
}
|
||||
|
||||
_updatedAssetSet.Clear();
|
||||
return root;
|
||||
}
|
||||
|
||||
private AssetViewItem CreateTree(string guid, ref int elementCount, int depth)
|
||||
{
|
||||
if (_parentAssetIsAdd.Contains(guid))
|
||||
return null;
|
||||
if (needUpdateState && !_updatedAssetSet.Contains(guid))
|
||||
{
|
||||
Data.UpdateAssetState(guid);
|
||||
_updatedAssetSet.Add(guid);
|
||||
}
|
||||
|
||||
++elementCount;
|
||||
ReferenceFinderData.AssetDescription referenceData = Data.assetDict[guid];
|
||||
AssetViewItem root = new AssetViewItem { id = elementCount, displayName = referenceData.name, data = referenceData, depth = depth };
|
||||
List<string> childGuids = _isDepend ? referenceData.dependencies : referenceData.references;
|
||||
_parentAssetIsAdd.Add(guid);
|
||||
foreach (string childGuid in childGuids)
|
||||
{
|
||||
if (_brotherAssetIsAdd.Contains(childGuid)) continue;
|
||||
ListInfo listInfo = new ListInfo();
|
||||
if (AssetDatabase.GUIDToAssetPath(childGuid).EndsWith(".mat") && depth < 2)
|
||||
{
|
||||
listInfo.Type = "mat";
|
||||
listInfo.Count = 1;
|
||||
listInfo.Name = Path.GetFileName(AssetDatabase.GUIDToAssetPath(childGuid));
|
||||
if (!_artInfo.TryAdd(root.displayName, listInfo))
|
||||
{
|
||||
_artInfo[root.displayName].Count += 1;
|
||||
_artInfo[root.displayName].Name += "<<==>>" + listInfo.Name;
|
||||
}
|
||||
}
|
||||
|
||||
if (AssetDatabase.GUIDToAssetPath(childGuid).EndsWith(".prefab") && !AssetDatabase.GUIDToAssetPath(childGuid).Contains("_gen_render") && depth < 2)
|
||||
{
|
||||
listInfo.Type = "prefab";
|
||||
listInfo.Count = 1;
|
||||
listInfo.Name = Path.GetFileName(AssetDatabase.GUIDToAssetPath(childGuid));
|
||||
if (!_artInfo.TryAdd(root.displayName, listInfo))
|
||||
{
|
||||
_artInfo[root.displayName].Count += 1;
|
||||
_artInfo[root.displayName].Name += "<<==>>" + listInfo.Name;
|
||||
}
|
||||
}
|
||||
|
||||
_brotherAssetIsAdd.Add(childGuid);
|
||||
AssetViewItem rs = CreateTree(childGuid, ref elementCount, depth + 1);
|
||||
if (rs != null)
|
||||
root.AddChild(rs);
|
||||
}
|
||||
|
||||
foreach (string childGuid in childGuids)
|
||||
{
|
||||
if (_brotherAssetIsAdd.Contains(childGuid))
|
||||
_brotherAssetIsAdd.Remove(childGuid);
|
||||
}
|
||||
|
||||
_parentAssetIsAdd.Remove(guid);
|
||||
return root;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 40f81b3f7b523ee46ab72ec79c7a61af
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,33 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TEngine.Editor
|
||||
{
|
||||
internal sealed class SortConfig
|
||||
{
|
||||
public static readonly Dictionary<SortType, SortType> SortTypeChangeByNameHandler = new Dictionary<SortType, SortType>
|
||||
{
|
||||
{ SortType.None, SortType.AscByName },
|
||||
{ SortType.AscByName, SortType.DescByName },
|
||||
{ SortType.DescByName, SortType.AscByName }
|
||||
};
|
||||
|
||||
public static readonly Dictionary<SortType, SortType> SortTypeChangeByPathHandler = new Dictionary<SortType, SortType>
|
||||
{
|
||||
{ SortType.None, SortType.AscByPath },
|
||||
{ SortType.AscByPath, SortType.DescByPath },
|
||||
{ SortType.DescByPath, SortType.AscByPath }
|
||||
};
|
||||
|
||||
public static readonly Dictionary<SortType, short> SortTypeGroup = new Dictionary<SortType, short>
|
||||
{
|
||||
{ SortType.None, 0 },
|
||||
{ SortType.AscByPath, 1 },
|
||||
{ SortType.DescByPath, 1 },
|
||||
{ SortType.AscByName, 2 },
|
||||
{ SortType.DescByName, 2 }
|
||||
};
|
||||
|
||||
public const short TYPE_BY_NAME_GROUP = 2;
|
||||
public const short TYPE_BY_PATH_GROUP = 1;
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2d7b92d1055376e4dbabd77de5a0e728
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,111 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TEngine.Editor
|
||||
{
|
||||
internal sealed class SortHelper
|
||||
{
|
||||
public delegate int SortCompare(string lString, string rString);
|
||||
|
||||
public static readonly HashSet<string> SortedGuid = new HashSet<string>();
|
||||
public static readonly Dictionary<string, SortType> SortedAsset = new Dictionary<string, SortType>();
|
||||
public static SortType CurSortType = SortType.None;
|
||||
public static SortType PathType = SortType.None;
|
||||
public static SortType NameType = SortType.None;
|
||||
|
||||
public static readonly Dictionary<SortType, SortCompare> CompareFunction = new Dictionary<SortType, SortCompare>
|
||||
{
|
||||
{ SortType.AscByPath, CompareWithPath },
|
||||
{ SortType.DescByPath, CompareWithPathDesc },
|
||||
{ SortType.AscByName, CompareWithName },
|
||||
{ SortType.DescByName, CompareWithNameDesc }
|
||||
};
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
SortedGuid.Clear();
|
||||
SortedAsset.Clear();
|
||||
}
|
||||
|
||||
public static void ChangeSortType(short sortGroup, Dictionary<SortType, SortType> handler, ref SortType recoverType)
|
||||
{
|
||||
if (SortConfig.SortTypeGroup[CurSortType] == sortGroup)
|
||||
{
|
||||
CurSortType = handler[CurSortType];
|
||||
}
|
||||
else
|
||||
{
|
||||
CurSortType = recoverType;
|
||||
if (CurSortType == SortType.None) CurSortType = handler[CurSortType];
|
||||
}
|
||||
|
||||
recoverType = CurSortType;
|
||||
}
|
||||
|
||||
public static void SortByName() => ChangeSortType(SortConfig.TYPE_BY_NAME_GROUP, SortConfig.SortTypeChangeByNameHandler, ref NameType);
|
||||
|
||||
public static void SortByPath() => ChangeSortType(SortConfig.TYPE_BY_PATH_GROUP, SortConfig.SortTypeChangeByPathHandler, ref PathType);
|
||||
|
||||
public static void SortChild(ReferenceFinderData.AssetDescription data)
|
||||
{
|
||||
if (data == null) return;
|
||||
if (SortedAsset.ContainsKey(data.path))
|
||||
{
|
||||
if (SortedAsset[data.path] == CurSortType) return;
|
||||
SortType oldSortType = SortedAsset[data.path];
|
||||
if (SortConfig.SortTypeGroup[oldSortType] == SortConfig.SortTypeGroup[CurSortType])
|
||||
{
|
||||
FastSort(data.dependencies);
|
||||
FastSort(data.references);
|
||||
}
|
||||
else
|
||||
{
|
||||
NormalSort(data.dependencies);
|
||||
NormalSort(data.references);
|
||||
}
|
||||
|
||||
SortedAsset[data.path] = CurSortType;
|
||||
}
|
||||
else
|
||||
{
|
||||
NormalSort(data.dependencies);
|
||||
NormalSort(data.references);
|
||||
SortedAsset.Add(data.path, CurSortType);
|
||||
}
|
||||
}
|
||||
|
||||
public static void NormalSort(List<string> strList)
|
||||
{
|
||||
SortCompare curCompare = CompareFunction[CurSortType];
|
||||
strList.Sort((l, r) => curCompare(l, r));
|
||||
}
|
||||
|
||||
public static void FastSort(List<string> strList)
|
||||
{
|
||||
int i = 0;
|
||||
int j = strList.Count - 1;
|
||||
while (i < j)
|
||||
{
|
||||
(strList[i], strList[j]) = (strList[j], strList[i]);
|
||||
i++;
|
||||
j--;
|
||||
}
|
||||
}
|
||||
|
||||
public static int CompareWithName(string lString, string rString)
|
||||
{
|
||||
Dictionary<string, ReferenceFinderData.AssetDescription> asset = ResourceReferenceInfo.Data.assetDict;
|
||||
return string.Compare(asset[lString].name, asset[rString].name, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
public static int CompareWithNameDesc(string lString, string rString) => 0 - CompareWithName(lString, rString);
|
||||
|
||||
public static int CompareWithPath(string lString, string rString)
|
||||
{
|
||||
Dictionary<string, ReferenceFinderData.AssetDescription> asset = ResourceReferenceInfo.Data.assetDict;
|
||||
return string.Compare(asset[lString].path, asset[rString].path, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
public static int CompareWithPathDesc(string lString, string rString) => 0 - CompareWithPath(lString, rString);
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f2a386b95a697364abaac53ed1cac83e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,11 +0,0 @@
|
||||
namespace TEngine.Editor
|
||||
{
|
||||
public enum SortType
|
||||
{
|
||||
None,
|
||||
AscByName,
|
||||
DescByName,
|
||||
AscByPath,
|
||||
DescByPath
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 86a3dbcbc8c8c7145bab4093920461da
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e11095ce128a7214a88c291ea368df9a
|
||||
guid: 075130c21aee41b49b3977adc2bfa288
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 443dd03b960c78d449f988aa5f00322a
|
||||
guid: 20dbf6614352aaf488de29690deeab68
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c3fabc41cf17c444995fc01a76c5dbe6
|
||||
guid: fb0502859d7561142a3408d0ce2a19d8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
@@ -0,0 +1,88 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityToolbarExtender;
|
||||
|
||||
namespace TEngine
|
||||
{
|
||||
[InitializeOnLoad]
|
||||
public class EditorPlayMode
|
||||
{
|
||||
static class ToolbarStyles
|
||||
{
|
||||
public static readonly GUIStyle ToolBarExtenderBtnStyle;
|
||||
|
||||
public static readonly GUIStyle ToolBarTextStyle;
|
||||
|
||||
public static readonly GUIStyle ToolBarButtonGuiStyle;
|
||||
|
||||
static ToolbarStyles()
|
||||
{
|
||||
ToolBarExtenderBtnStyle = new GUIStyle("Command")
|
||||
{
|
||||
fontSize = 12,
|
||||
alignment = TextAnchor.MiddleCenter,
|
||||
imagePosition = ImagePosition.ImageAbove,
|
||||
fontStyle = FontStyle.Normal,
|
||||
fixedWidth = 60
|
||||
};
|
||||
|
||||
ToolBarTextStyle = new GUIStyle(BUTTON_STYLE_NAME)
|
||||
{
|
||||
padding = new RectOffset(2, 8, 2, 2),
|
||||
alignment = TextAnchor.MiddleCenter,
|
||||
fontStyle = FontStyle.Bold
|
||||
};
|
||||
|
||||
ToolBarButtonGuiStyle = new GUIStyle(BUTTON_STYLE_NAME)
|
||||
{
|
||||
padding = new RectOffset(2, 8, 2, 2),
|
||||
alignment = TextAnchor.MiddleCenter,
|
||||
fontStyle = FontStyle.Bold
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
static EditorPlayMode()
|
||||
{
|
||||
ToolbarExtender.RightToolbarGUI.Add(OnToolbarGUI);
|
||||
_resourceModeIndex = EditorPrefs.GetInt("EditorPlayMode", 0);
|
||||
}
|
||||
|
||||
private const string BUTTON_STYLE_NAME = "Tab middle";
|
||||
static GUIStyle _buttonGuiStyle;
|
||||
|
||||
private static readonly string[] _resourceModeNames =
|
||||
{
|
||||
"EditorMode (编辑器下的模拟模式)",
|
||||
"OfflinePlayMode (单机模式)",
|
||||
"HostPlayMode (联机运行模式)",
|
||||
"WebPlayMode (WebGL运行模式)"
|
||||
};
|
||||
|
||||
private static int _resourceModeIndex = 0;
|
||||
public static int ResourceModeIndex => _resourceModeIndex;
|
||||
|
||||
static void OnToolbarGUI()
|
||||
{
|
||||
EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
|
||||
{
|
||||
// GUILayout.Label("资源加载模式:",ToolbarStyles.ToolBarTextStyle);
|
||||
//GUILayout.Space(10);
|
||||
//GUILayout.FlexibleSpace();
|
||||
|
||||
// 资源模式
|
||||
int selectedIndex = EditorGUILayout.Popup("", _resourceModeIndex, _resourceModeNames, ToolbarStyles.ToolBarButtonGuiStyle);
|
||||
// ReSharper disable once RedundantCheckBeforeAssignment
|
||||
if (selectedIndex != _resourceModeIndex)
|
||||
{
|
||||
Debug.Log($"更改编辑器资源运行模式 : {_resourceModeNames[selectedIndex]}");
|
||||
_resourceModeIndex = selectedIndex;
|
||||
EditorPrefs.SetInt("EditorPlayMode", selectedIndex);
|
||||
}
|
||||
//GUILayout.FlexibleSpace();
|
||||
//GUILayout.Space(400);
|
||||
}
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
}
|
||||
}
|
@@ -4,9 +4,10 @@ using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityToolbarExtender;
|
||||
|
||||
namespace TEngine
|
||||
namespace TEngine.SceneLauncher
|
||||
{
|
||||
public partial class UnityToolbarExtenderLeft
|
||||
[InitializeOnLoad]
|
||||
public class SceneSwitchLeftButton
|
||||
{
|
||||
private const string PreviousSceneKey = "TEngine_PreviousScenePath"; // 用于存储之前场景路径的键
|
||||
private const string IsLauncherBtn = "TEngine_IsLauncher"; // 用于存储之前是否按下launcher
|
||||
@@ -16,7 +17,14 @@ namespace TEngine
|
||||
private static readonly string ButtonStyleName = "Tab middle";
|
||||
private static GUIStyle _buttonGuiStyle;
|
||||
|
||||
private static void OnToolbarGUI_SceneLauncher()
|
||||
static SceneSwitchLeftButton()
|
||||
{
|
||||
ToolbarExtender.LeftToolbarGUI.Add(OnToolbarGUI);
|
||||
EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
|
||||
EditorApplication.quitting += OnEditorQuit;
|
||||
}
|
||||
|
||||
private static void OnToolbarGUI()
|
||||
{
|
||||
_buttonGuiStyle ??= new GUIStyle(ButtonStyleName)
|
||||
{
|
@@ -0,0 +1,115 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEditor.SceneManagement;
|
||||
|
||||
namespace UnityToolbarExtender.Examples
|
||||
{
|
||||
[InitializeOnLoad]
|
||||
public sealed class SceneSwitchLeftButton
|
||||
{
|
||||
private static List<(string sceneName, string scenePath)> m_Scenes;
|
||||
private static string[] m_SceneName;
|
||||
private static string[] m_ScenePath;
|
||||
private static int sceneSelected = 0;
|
||||
|
||||
static SceneSwitchLeftButton()
|
||||
{
|
||||
EditorApplication.projectChanged += UpdateCurrent;
|
||||
UpdateCurrent();
|
||||
ToolbarExtender.RightToolbarGUI.Add(OnToolbarGUI);
|
||||
}
|
||||
|
||||
static void UpdateCurrent()
|
||||
{
|
||||
m_Scenes = SceneSwitcher.GetAllScenesInProject();
|
||||
m_SceneName = new string[m_Scenes.Count];
|
||||
m_ScenePath = new string[m_Scenes.Count];
|
||||
for (int i = 0; i < m_Scenes.Count; i++)
|
||||
{
|
||||
var (name, path) = m_Scenes[i];
|
||||
m_SceneName[i] = name;
|
||||
m_ScenePath[i] = path;
|
||||
if (SceneManager.GetActiveScene().path == path)
|
||||
sceneSelected = i;
|
||||
}
|
||||
}
|
||||
|
||||
static void OnToolbarGUI()
|
||||
{
|
||||
if (sceneSelected >= m_SceneName.Length) //空项目0场景判断
|
||||
return;
|
||||
var size = EditorStyles.popup.CalcSize(new GUIContent(m_SceneName[sceneSelected]));
|
||||
// 创建水平布局
|
||||
//EditorGUILayout.BeginHorizontal();
|
||||
GUILayout.Space(20);
|
||||
// 将控件推到左边和右边
|
||||
//GUILayout.FlexibleSpace(); // 先占用左边的所有空间
|
||||
EditorGUILayout.LabelField("当前场景:", GUILayout.Width(55));
|
||||
int sceneSelectedNew = EditorGUILayout.Popup(sceneSelected, m_SceneName, GUILayout.Width(size.x + 5f),
|
||||
GUILayout.MinWidth(55));
|
||||
GUILayout.FlexibleSpace();
|
||||
// 结束水平布局
|
||||
//EditorGUILayout.EndHorizontal();
|
||||
if (sceneSelectedNew != sceneSelected)
|
||||
{
|
||||
sceneSelected = sceneSelectedNew;
|
||||
SceneSwitcher.PromptSaveCurrentScene();
|
||||
EditorSceneManager.OpenScene(m_ScenePath[sceneSelectedNew]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class SceneSwitcher
|
||||
{
|
||||
public static bool PromptSaveCurrentScene()
|
||||
{
|
||||
// 检查当前场景是否已保存
|
||||
if (SceneManager.GetActiveScene().isDirty)
|
||||
{
|
||||
// 提示用户是否要保存当前场景
|
||||
bool saveScene = EditorUtility.DisplayDialog(
|
||||
"Save Current Scene",
|
||||
"The current scene has unsaved changes. Do you want to save it?",
|
||||
"Save",
|
||||
"Cancel"
|
||||
);
|
||||
|
||||
// 如果用户选择“保存”,则保存当前场景
|
||||
if (saveScene)
|
||||
{
|
||||
EditorSceneManager.SaveScene(SceneManager.GetActiveScene());
|
||||
}
|
||||
|
||||
return saveScene;
|
||||
}
|
||||
|
||||
// 如果场景已保存或者用户选择了“取消”,则返回 true,表示继续执行后续操作
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取项目中所有的场景文件,并以 (场景名, 场景路径) 的形式返回。
|
||||
/// </summary>
|
||||
public static List<(string sceneName, string scenePath)> GetAllScenesInProject()
|
||||
{
|
||||
List<(string sceneName, string scenePath)> scenes = new List<(string sceneName, string scenePath)>();
|
||||
|
||||
// 查找所有场景文件
|
||||
string[] guids = AssetDatabase.FindAssets("t:Scene");
|
||||
for (int i = 0; i < guids.Length; i++)
|
||||
{
|
||||
var guid = guids[i];
|
||||
string path = AssetDatabase.GUIDToAssetPath(guid);
|
||||
string sceneName = $"{i + 1}_{Path.GetFileNameWithoutExtension(path)}";
|
||||
scenes.Add((sceneName, path));
|
||||
}
|
||||
|
||||
return scenes;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -1,16 +0,0 @@
|
||||
using UnityEditor;
|
||||
using UnityToolbarExtender;
|
||||
|
||||
namespace TEngine
|
||||
{
|
||||
[InitializeOnLoad]
|
||||
public partial class UnityToolbarExtenderLeft
|
||||
{
|
||||
static UnityToolbarExtenderLeft()
|
||||
{
|
||||
ToolbarExtender.LeftToolbarGUI.Add(OnToolbarGUI_SceneLauncher);
|
||||
EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
|
||||
EditorApplication.quitting += OnEditorQuit;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c4485948c7a944af943177214f7f5033
|
||||
timeCreated: 1748228552
|
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a225fc80e4bc4e24caa14cb50ce08109
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,79 +0,0 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityToolbarExtender;
|
||||
|
||||
namespace TEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// EditorPlayMode 控件(资源模式选择器)
|
||||
/// </summary>
|
||||
public partial class UnityToolbarExtenderRight
|
||||
{
|
||||
private const string BUTTON_STYLE_NAME = "Tab middle";
|
||||
|
||||
private static readonly string[] _resourceModeNames =
|
||||
{
|
||||
"EditorMode (编辑器下的模拟模式)",
|
||||
"OfflinePlayMode (单机模式)",
|
||||
"HostPlayMode (联机运行模式)",
|
||||
"WebPlayMode (WebGL运行模式)"
|
||||
};
|
||||
|
||||
private static int _resourceModeIndex = 0;
|
||||
public static int ResourceModeIndex => _resourceModeIndex;
|
||||
|
||||
static class ToolbarStyles
|
||||
{
|
||||
public static readonly GUIStyle PopupStyle;
|
||||
|
||||
static ToolbarStyles()
|
||||
{
|
||||
PopupStyle = new GUIStyle(EditorStyles.popup)
|
||||
{
|
||||
//fontSize = 11,
|
||||
alignment = TextAnchor.MiddleLeft,
|
||||
padding = new RectOffset(6, 6, 0, 0)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
static void OnToolbarGUI_EditorPlayMode()
|
||||
{
|
||||
EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
|
||||
{
|
||||
GUILayout.Space(8);
|
||||
|
||||
// 自动计算最长文本宽度
|
||||
float maxWidth = 0;
|
||||
foreach (string mode in _resourceModeNames)
|
||||
{
|
||||
Vector2 size = ToolbarStyles.PopupStyle.CalcSize(new GUIContent(mode));
|
||||
if (size.x > maxWidth)
|
||||
maxWidth = size.x;
|
||||
}
|
||||
|
||||
// 加点缓冲宽度(最多不超过220像素)
|
||||
float popupWidth = Mathf.Clamp(maxWidth + 20, 100, 220);
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
//GUILayout.Label("资源模式:", GUILayout.Width(65));
|
||||
|
||||
int selectedIndex = EditorGUILayout.Popup(
|
||||
_resourceModeIndex,
|
||||
_resourceModeNames,
|
||||
ToolbarStyles.PopupStyle,
|
||||
GUILayout.Width(popupWidth)
|
||||
);
|
||||
|
||||
if (selectedIndex != _resourceModeIndex)
|
||||
{
|
||||
Debug.Log($"更改编辑器资源运行模式:{_resourceModeNames[selectedIndex]}");
|
||||
_resourceModeIndex = selectedIndex;
|
||||
EditorPrefs.SetInt("EditorPlayMode", selectedIndex);
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,170 +0,0 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEditor.SceneManagement;
|
||||
|
||||
namespace TEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// SceneSwitcher
|
||||
/// </summary>
|
||||
public partial class UnityToolbarExtenderRight
|
||||
{
|
||||
private static List<(string sceneName, string scenePath)> m_InitScenes;
|
||||
private static List<(string sceneName, string scenePath)> m_DefaultScenes;
|
||||
private static List<(string sceneName, string scenePath)> m_OtherScenes;
|
||||
|
||||
private static string initScenePath = "Assets/Scenes";
|
||||
private static string defaultScenePath = "Assets/AssetRaw/Scenes";
|
||||
|
||||
static void UpdateScenes()
|
||||
{
|
||||
// 获取初始化场景和默认场景
|
||||
m_InitScenes = SceneSwitcher.GetScenesInPath(initScenePath);
|
||||
m_DefaultScenes = SceneSwitcher.GetScenesInPath(defaultScenePath);
|
||||
|
||||
// 获取所有场景路径
|
||||
List<(string sceneName, string scenePath)> allScenes = SceneSwitcher.GetAllScenes();
|
||||
|
||||
// 排除初始化场景和默认场景,获得其他场景
|
||||
m_OtherScenes = new List<(string sceneName, string scenePath)>(allScenes);
|
||||
m_OtherScenes.RemoveAll(scene =>
|
||||
m_InitScenes.Exists(init => init.scenePath == scene.scenePath) ||
|
||||
m_DefaultScenes.Exists(defaultScene => defaultScene.scenePath == scene.scenePath)
|
||||
);
|
||||
}
|
||||
|
||||
static void OnToolbarGUI_SceneSwitch()
|
||||
{
|
||||
// 如果没有场景,直接返回
|
||||
if (m_InitScenes.Count == 0 && m_DefaultScenes.Count == 0 && m_OtherScenes.Count == 0)
|
||||
return;
|
||||
|
||||
// 获取当前场景名称
|
||||
string currentSceneName = SceneManager.GetActiveScene().name;
|
||||
EditorGUILayout.LabelField("当前场景:", GUILayout.Width(52));
|
||||
|
||||
// 使用 GUI.skin.button.CalcSize 计算文本的精确宽度
|
||||
GUIContent content = new GUIContent(currentSceneName);
|
||||
Vector2 textSize = GUI.skin.button.CalcSize(content);
|
||||
|
||||
// 设置按钮宽度为文本的宽度,并限制最大值
|
||||
float buttonWidth = textSize.x;
|
||||
|
||||
// 创建弹出菜单
|
||||
var menu = new GenericMenu();
|
||||
|
||||
// 添加 "初始化路径" 下的场景按钮
|
||||
AddScenesToMenu(m_InitScenes, "初始化场景", menu);
|
||||
|
||||
// 添加 "默认路径" 下的场景按钮
|
||||
AddScenesToMenu(m_DefaultScenes, "默认场景", menu);
|
||||
|
||||
// 添加 "其他路径" 下的场景按钮
|
||||
AddScenesToMenu(m_OtherScenes, "其他场景", menu);
|
||||
|
||||
// 自定义GUIStyle
|
||||
GUIStyle buttonStyle = new GUIStyle(GUI.skin.button)
|
||||
{
|
||||
alignment = TextAnchor.MiddleLeft // 左对齐
|
||||
};
|
||||
|
||||
// 在工具栏中显示菜单
|
||||
if (GUILayout.Button(currentSceneName, buttonStyle, GUILayout.Width(buttonWidth)))
|
||||
{
|
||||
menu.ShowAsContext();
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddScenesToMenu(List<(string sceneName, string scenePath)> scenes, string category, GenericMenu menu)
|
||||
{
|
||||
if (scenes.Count > 0)
|
||||
{
|
||||
foreach (var scene in scenes)
|
||||
{
|
||||
menu.AddItem(new GUIContent($"{category}/{scene.sceneName}"), false, () => SwitchScene(scene.scenePath));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchScene(string scenePath)
|
||||
{
|
||||
// 保证场景是否保存
|
||||
if (SceneSwitcher.PromptSaveCurrentScene())
|
||||
{
|
||||
// 保存场景后切换到新场景
|
||||
EditorSceneManager.OpenScene(scenePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class SceneSwitcher
|
||||
{
|
||||
public static bool PromptSaveCurrentScene()
|
||||
{
|
||||
// 检查当前场景是否有未保存的更改
|
||||
if (SceneManager.GetActiveScene().isDirty)
|
||||
{
|
||||
// 弹出保存对话框
|
||||
bool saveScene = EditorUtility.DisplayDialog(
|
||||
"是否保存当前场景",
|
||||
"当前场景有未保存的更改. 你是否想保存?",
|
||||
"保存",
|
||||
"取消"
|
||||
);
|
||||
|
||||
// 如果选择保存,保存场景
|
||||
if (saveScene)
|
||||
{
|
||||
EditorSceneManager.SaveScene(SceneManager.GetActiveScene());
|
||||
}
|
||||
else
|
||||
{
|
||||
// 如果选择取消,跳转到目标场景
|
||||
return false; // 表示取消
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true; // 如果场景没有更改,直接返回 true
|
||||
}
|
||||
|
||||
public static List<(string sceneName, string scenePath)> GetScenesInPath(string path)
|
||||
{
|
||||
var scenes = new List<(string sceneName, string scenePath)>();
|
||||
|
||||
// 查找指定路径下的所有场景文件
|
||||
string[] guids = AssetDatabase.FindAssets("t:Scene", new[] { path });
|
||||
foreach (var guid in guids)
|
||||
{
|
||||
var scenePath = AssetDatabase.GUIDToAssetPath(guid);
|
||||
var sceneName = Path.GetFileNameWithoutExtension(scenePath);
|
||||
scenes.Add((sceneName, scenePath));
|
||||
}
|
||||
|
||||
return scenes;
|
||||
}
|
||||
|
||||
// 获取项目中所有场景
|
||||
public static List<(string sceneName, string scenePath)> GetAllScenes()
|
||||
{
|
||||
var allScenes = new List<(string sceneName, string scenePath)>();
|
||||
|
||||
// 查找项目中所有场景文件
|
||||
string[] guids = AssetDatabase.FindAssets("t:Scene");
|
||||
foreach (var guid in guids)
|
||||
{
|
||||
var scenePath = AssetDatabase.GUIDToAssetPath(guid);
|
||||
var sceneName = Path.GetFileNameWithoutExtension(scenePath);
|
||||
allScenes.Add((sceneName, scenePath));
|
||||
}
|
||||
|
||||
return allScenes;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -1,21 +0,0 @@
|
||||
using UnityEditor;
|
||||
using UnityToolbarExtender;
|
||||
|
||||
namespace TEngine
|
||||
{
|
||||
[InitializeOnLoad]
|
||||
public partial class UnityToolbarExtenderRight
|
||||
{
|
||||
|
||||
static UnityToolbarExtenderRight()
|
||||
{
|
||||
// 添加自定义按钮到右上工具栏
|
||||
ToolbarExtender.RightToolbarGUI.Add(OnToolbarGUI_SceneSwitch);
|
||||
// 订阅项目变化事件
|
||||
EditorApplication.projectChanged += UpdateScenes;
|
||||
UpdateScenes();
|
||||
ToolbarExtender.RightToolbarGUI.Add(OnToolbarGUI_EditorPlayMode);
|
||||
_resourceModeIndex = EditorPrefs.GetInt("EditorPlayMode", 0);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6240714bc0004010a4d6ca42a4f4305e
|
||||
timeCreated: 1748227857
|
@@ -68,7 +68,7 @@ namespace TEngine.Editor.UI
|
||||
}
|
||||
else
|
||||
{
|
||||
strFile.Append($"\t[Window(UILayer.UI,location:\"{root.name}\")]\n");
|
||||
strFile.Append("\t[Window(UILayer.UI)]\n");
|
||||
strFile.Append("\tclass " + root.name + " : UIWindow\n");
|
||||
}
|
||||
|
||||
|
@@ -1,9 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using GameLogic;
|
||||
#if ENABLE_OBFUZ
|
||||
using Obfuz;
|
||||
#endif
|
||||
using TEngine;
|
||||
#pragma warning disable CS0436
|
||||
|
||||
@@ -11,9 +8,6 @@ using TEngine;
|
||||
/// <summary>
|
||||
/// 游戏App。
|
||||
/// </summary>
|
||||
#if ENABLE_OBFUZ
|
||||
[ObfuzIgnore(ObfuzScope.TypeName | ObfuzScope.MethodName)]
|
||||
#endif
|
||||
public partial class GameApp
|
||||
{
|
||||
private static List<Assembly> _hotfixAssembly;
|
||||
@@ -29,13 +23,12 @@ public partial class GameApp
|
||||
Log.Warning("======= 看到此条日志代表你成功运行了热更新代码 =======");
|
||||
Log.Warning("======= Entrance GameApp =======");
|
||||
Utility.Unity.AddDestroyListener(Release);
|
||||
Log.Warning("======= StartGameLogic =======");
|
||||
StartGameLogic();
|
||||
}
|
||||
|
||||
private static void StartGameLogic()
|
||||
{
|
||||
// GameEvent.Get<ILoginUI>().ShowLoginUI();
|
||||
GameEvent.Get<ILoginUI>().ShowLoginUI();
|
||||
GameModule.UI.ShowUIAsync<BattleMainUI>();
|
||||
}
|
||||
|
||||
|
@@ -10,8 +10,7 @@
|
||||
"GUID:47f9fc774596be54ebfed7739cd70c86",
|
||||
"GUID:1aa3e8589868c80499255710874679c0",
|
||||
"GUID:d8b63aba1907145bea998dd612889d6b",
|
||||
"GUID:756335c0388f7114790e504ed368ae1d",
|
||||
"GUID:4140bd2e2764f1f47ab93125ecb61942"
|
||||
"GUID:756335c0388f7114790e504ed368ae1d"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
@@ -4,7 +4,7 @@ using TEngine;
|
||||
|
||||
namespace GameLogic
|
||||
{
|
||||
[Window(UILayer.UI,location:"BattleMainUI")]
|
||||
[Window(UILayer.UI)]
|
||||
class BattleMainUI : UIWindow
|
||||
{
|
||||
#region 脚本工具生成的代码
|
||||
|
@@ -2,8 +2,7 @@
|
||||
"name": "Launcher",
|
||||
"rootNamespace": "Launcher",
|
||||
"references": [
|
||||
"GUID:13ba8ce62aa80c74598530029cb2d649",
|
||||
"GUID:4140bd2e2764f1f47ab93125ecb61942"
|
||||
"GUID:13ba8ce62aa80c74598530029cb2d649"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
@@ -63,7 +63,6 @@ namespace Launcher
|
||||
{
|
||||
ui.transform.SetParent(_uiRoot.transform);
|
||||
ui.transform.localScale = Vector3.one;
|
||||
ui.transform.localRotation = Quaternion.identity;
|
||||
ui.transform.localPosition = Vector3.zero;
|
||||
RectTransform rect = ui.GetComponent<RectTransform>();
|
||||
rect.sizeDelta = Vector2.zero;
|
||||
|
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2daec965c12426d4c81fd26f8cf380e4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 673c197d012a9c549be6c6991ad3fb30
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,24 +0,0 @@
|
||||
using Obfuz;
|
||||
using Obfuz.EncryptionVM;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Launcher
|
||||
{
|
||||
public class ObfuzInitialize : MonoBehaviour
|
||||
{
|
||||
// 初始化EncryptionService后被混淆的代码才能正常运行,
|
||||
// 因此尽可能地早地初始化它。
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)]
|
||||
private static void SetUpStaticSecretKey()
|
||||
{
|
||||
#if ENABLE_OBFUZ
|
||||
Debug.Log("Enable Obfuz");
|
||||
Debug.Log("SetUpStaticSecret begin");
|
||||
EncryptionService<DefaultStaticEncryptionScope>.Encryptor = new GeneratedEncryptionVirtualMachine(Resources.Load<TextAsset>("Obfuz/defaultStaticSecretKey").bytes);
|
||||
Debug.Log("SetUpStaticSecret end");
|
||||
#else
|
||||
Debug.Log("Disable Obfuz");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 883bcac172734133a1972a05275df53b
|
||||
timeCreated: 1753458333
|
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 25a2e7cc325e1054db9d6fd1189d5474
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8b16602403e80c24f85f2d87b7db8bcf
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca6f6fb6ba786e14fb3096bd01f61ac5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 029862980bde3c9489ef31bf924728e3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ed52d75209dd9e4c81e0cab914d053c
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a1c5d75e786680342b0e358f67064ac8
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -38,6 +38,7 @@ RenderSettings:
|
||||
m_ReflectionIntensity: 1
|
||||
m_CustomReflection: {fileID: 0}
|
||||
m_Sun: {fileID: 0}
|
||||
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_UseRadianceAmbientProbe: 0
|
||||
--- !u!157 &3
|
||||
LightmapSettings:
|
||||
|
@@ -203,20 +203,11 @@
|
||||
{
|
||||
if (_atlasMap.TryGetValue(atlasName, out List<string> spriteList))
|
||||
{
|
||||
var allSprites = new List<Sprite>();
|
||||
|
||||
foreach (var assetPath in spriteList.Where(File.Exists))
|
||||
{
|
||||
// 加载所有子图
|
||||
var sprites = AssetDatabase.LoadAllAssetsAtPath(assetPath)
|
||||
.OfType<Sprite>()
|
||||
.Where(s => s != null)
|
||||
.ToArray();
|
||||
|
||||
allSprites.AddRange(sprites);
|
||||
}
|
||||
|
||||
return allSprites;
|
||||
return spriteList
|
||||
.Where(File.Exists)
|
||||
.Select(AssetDatabase.LoadAssetAtPath<Sprite>)
|
||||
.Where(s => s)
|
||||
.ToList();
|
||||
}
|
||||
return new List<Sprite>();
|
||||
}
|
||||
|
@@ -2,10 +2,6 @@
|
||||
using HybridCLR.Editor;
|
||||
using HybridCLR.Editor.Commands;
|
||||
#endif
|
||||
using System.IO;
|
||||
using Obfuz.Settings;
|
||||
using Obfuz4HybridCLR;
|
||||
using System.Collections.Generic;
|
||||
using TEngine.Editor;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
@@ -13,14 +9,12 @@ using UnityEngine;
|
||||
public static class BuildDLLCommand
|
||||
{
|
||||
private const string EnableHybridClrScriptingDefineSymbol = "ENABLE_HYBRIDCLR";
|
||||
private const string EnableObfuzScriptingDefineSymbol = "ENABLE_OBFUZ";
|
||||
|
||||
#region HybridCLR/Define Symbols
|
||||
/// <summary>
|
||||
/// 禁用HybridCLR宏定义。
|
||||
/// </summary>
|
||||
[MenuItem("HybridCLR/Define Symbols/Disable HybridCLR", false, 30)]
|
||||
public static void DisableHybridCLR()
|
||||
public static void Disable()
|
||||
{
|
||||
ScriptingDefineSymbols.RemoveScriptingDefineSymbol(EnableHybridClrScriptingDefineSymbol);
|
||||
#if ENABLE_HYBRIDCLR
|
||||
@@ -33,7 +27,7 @@ public static class BuildDLLCommand
|
||||
/// 开启HybridCLR宏定义。
|
||||
/// </summary>
|
||||
[MenuItem("HybridCLR/Define Symbols/Enable HybridCLR", false, 31)]
|
||||
public static void EnableHybridCLR()
|
||||
public static void Enable()
|
||||
{
|
||||
ScriptingDefineSymbols.RemoveScriptingDefineSymbol(EnableHybridClrScriptingDefineSymbol);
|
||||
ScriptingDefineSymbols.AddScriptingDefineSymbol(EnableHybridClrScriptingDefineSymbol);
|
||||
@@ -42,31 +36,6 @@ public static class BuildDLLCommand
|
||||
UpdateSettingEditor.ForceUpdateAssemblies();
|
||||
#endif
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Obfuz/Define Symbols
|
||||
/// <summary>
|
||||
/// 禁用Obfuz宏定义。
|
||||
/// </summary>
|
||||
[MenuItem("Obfuz/Define Symbols/Disable Obfuz", false, 30)]
|
||||
public static void DisableObfuz()
|
||||
{
|
||||
ScriptingDefineSymbols.RemoveScriptingDefineSymbol(EnableObfuzScriptingDefineSymbol);
|
||||
ObfuzSettings.Instance.buildPipelineSettings.enable = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开启Obfuz宏定义。
|
||||
/// </summary>
|
||||
[MenuItem("Obfuz/Define Symbols/Enable Obfuz", false, 31)]
|
||||
public static void EnableObfuz()
|
||||
{
|
||||
ScriptingDefineSymbols.RemoveScriptingDefineSymbol(EnableObfuzScriptingDefineSymbol);
|
||||
ScriptingDefineSymbols.AddScriptingDefineSymbol(EnableObfuzScriptingDefineSymbol);
|
||||
ObfuzSettings.Instance.buildPipelineSettings.enable = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
[MenuItem("HybridCLR/Build/BuildAssets And CopyTo AssemblyTextAssetPath")]
|
||||
public static void BuildAndCopyDlls()
|
||||
@@ -90,31 +59,6 @@ public static class BuildDLLCommand
|
||||
{
|
||||
CopyAOTAssembliesToAssetPath();
|
||||
CopyHotUpdateAssembliesToAssetPath();
|
||||
|
||||
#if ENABLE_HYBRIDCLR && ENABLE_OBFUZ
|
||||
CompileDllCommand.CompileDll(target);
|
||||
|
||||
string obfuscatedHotUpdateDllPath = PrebuildCommandExt.GetObfuscatedHotUpdateAssemblyOutputPath(target);
|
||||
ObfuscateUtil.ObfuscateHotUpdateAssemblies(target, obfuscatedHotUpdateDllPath);
|
||||
|
||||
Directory.CreateDirectory(Application.streamingAssetsPath);
|
||||
|
||||
string hotUpdateDllPath = $"{SettingsUtil.GetHotUpdateDllsOutputDirByTarget(target)}";
|
||||
List<string> obfuscationRelativeAssemblyNames = ObfuzSettings.Instance.assemblySettings.GetObfuscationRelativeAssemblyNames();
|
||||
|
||||
foreach (string assName in SettingsUtil.HotUpdateAssemblyNamesIncludePreserved)
|
||||
{
|
||||
string srcDir = obfuscationRelativeAssemblyNames.Contains(assName) ? obfuscatedHotUpdateDllPath : hotUpdateDllPath;
|
||||
string srcFile = $"{srcDir}/{assName}.dll";
|
||||
string dstFile = Application.dataPath +"/"+ TEngine.Settings.UpdateSetting.AssemblyTextAssetPath + $"/{assName}.dll.bytes";
|
||||
if (File.Exists(srcFile))
|
||||
{
|
||||
File.Copy(srcFile, dstFile, true);
|
||||
Debug.Log($"[CompileAndObfuscate] Copy {srcFile} to {dstFile}");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
|
@@ -57,89 +57,14 @@ namespace TEngine
|
||||
Debug.LogWarning($"Start BuildPackage BuildTarget:{target} outputPath:{outputRoot}");
|
||||
}
|
||||
|
||||
[MenuItem("TEngine/Build/一键打包AssetBundle _F8")]
|
||||
[MenuItem("TEngine/Build/一键打包AssetBundle")]
|
||||
public static void BuildCurrentPlatformAB()
|
||||
{
|
||||
BuildDLLCommand.BuildAndCopyDlls();
|
||||
BuildTarget target = EditorUserBuildSettings.activeBuildTarget;
|
||||
BuildInternal(target, Application.dataPath + "/../Builds/", packageVersion: GetBuildPackageVersion());
|
||||
AssetDatabase.Refresh();
|
||||
//复制到打包后的StreamingAssets
|
||||
CopyStreamingAssetsFiles();
|
||||
}
|
||||
/// <summary>
|
||||
/// 复制StreamingAssets文件去打包目录
|
||||
/// </summary>
|
||||
public static void CopyStreamingAssetsFiles()
|
||||
{
|
||||
if (!Settings.UpdateSetting.IsAutoAssetCopeToBuildAddress())
|
||||
{
|
||||
Debug.Log("UpdateSetting.IsAutoAssetCopeToBuildAddress关闭,并不会生产到打包目录中");
|
||||
return;
|
||||
}
|
||||
// 获取StreamingAssets路径
|
||||
string streamingAssetsPath = Application.streamingAssetsPath;
|
||||
|
||||
// 目标路径,可以是任何你想要的目录
|
||||
string targetPath = Settings.UpdateSetting.GetBuildAddress();
|
||||
|
||||
// 判断目标路径是相对路径还是绝对路径
|
||||
if (!System.IO.Path.IsPathRooted(targetPath))
|
||||
{
|
||||
// 如果是相对路径,结合 StreamingAssets 的路径进行合并
|
||||
targetPath = System.IO.Path.Combine(streamingAssetsPath, targetPath);
|
||||
}
|
||||
|
||||
// 如果目标目录不存在,创建它
|
||||
if (!System.IO.Directory.Exists(targetPath))
|
||||
{
|
||||
Debug.LogError("打包目录不存在,检查UpdateSetting BuildAddress:"+targetPath);
|
||||
return;
|
||||
}
|
||||
// 删除目标路径下的所有文件
|
||||
string[] Deletefiles = System.IO.Directory.GetFiles(targetPath);
|
||||
foreach (var file in Deletefiles)
|
||||
{
|
||||
System.IO.File.Delete(file);
|
||||
Debug.Log($"删除文件: {file}");
|
||||
}
|
||||
|
||||
// 删除目标路径下的所有子目录
|
||||
string[] directories = System.IO.Directory.GetDirectories(targetPath);
|
||||
foreach (var directory in directories)
|
||||
{
|
||||
System.IO.Directory.Delete(directory, true); // true 表示递归删除子目录及其中内容
|
||||
Debug.Log($"删除目录: {directory}");
|
||||
}
|
||||
|
||||
// 获取StreamingAssets中的所有文件,排除.meta文件
|
||||
string[] files = System.IO.Directory.GetFiles(streamingAssetsPath, "*", System.IO.SearchOption.AllDirectories);
|
||||
|
||||
// 遍历并复制文件到目标目录
|
||||
foreach (var file in files)
|
||||
{
|
||||
// 排除.meta文件
|
||||
if (file.EndsWith(".meta"))
|
||||
continue;
|
||||
|
||||
// 获取相对路径,用于在目标目录中创建相同的文件结构
|
||||
string relativePath = file.Substring(streamingAssetsPath.Length + 1);
|
||||
string destinationFilePath = System.IO.Path.Combine(targetPath, relativePath);
|
||||
|
||||
// 确保目标文件夹存在
|
||||
string destinationDir = System.IO.Path.GetDirectoryName(destinationFilePath);
|
||||
if (!System.IO.Directory.Exists(destinationDir))
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(destinationDir);
|
||||
}
|
||||
|
||||
// 复制文件
|
||||
System.IO.File.Copy(file, destinationFilePath, true); // true 表示覆盖已存在的文件
|
||||
|
||||
|
||||
}
|
||||
Debug.Log($"复制文件完成:{targetPath}");
|
||||
}
|
||||
private static BuildTarget GetBuildTarget(string platform)
|
||||
{
|
||||
BuildTarget target = BuildTarget.NoTarget;
|
||||
@@ -205,8 +130,6 @@ namespace TEngine
|
||||
buildParameters = scriptableBuildParameters;
|
||||
|
||||
scriptableBuildParameters.CompressOption = ECompressOption.LZ4;
|
||||
|
||||
scriptableBuildParameters.BuiltinShadersBundleName = GetBuiltinShaderBundleName("DefaultPackage");
|
||||
}
|
||||
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
@@ -226,6 +149,7 @@ namespace TEngine
|
||||
buildParameters.ClearBuildCacheFiles = false; //不清理构建缓存,启用增量构建,可以提高打包速度!
|
||||
buildParameters.UseAssetDependencyDB = true; //使用资源依赖关系数据库,可以提高打包速度!
|
||||
|
||||
|
||||
var buildResult = pipeline.Run(buildParameters, true);
|
||||
if (buildResult.Success)
|
||||
{
|
||||
@@ -237,23 +161,12 @@ namespace TEngine
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 内置着色器资源包名称
|
||||
/// 注意:和自动收集的着色器资源包名保持一致!
|
||||
/// </summary>
|
||||
private static string GetBuiltinShaderBundleName(string packageName)
|
||||
{
|
||||
var uniqueBundleName = AssetBundleCollectorSettingData.Setting.UniqueBundleName;
|
||||
var packRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
||||
return packRuleResult.GetBundleName(packageName, uniqueBundleName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建加密类实例
|
||||
/// </summary>
|
||||
private static IEncryptionServices CreateEncryptionInstance(string packageName, EBuildPipeline buildPipeline)
|
||||
{
|
||||
var encryptionClassName = AssetBundleBuilderSetting.GetPackageEncyptionServicesClassName(packageName, buildPipeline.ToString());
|
||||
var encryptionClassName = AssetBundleBuilderSetting.GetPackageEncyptionClassName(packageName, buildPipeline);
|
||||
var encryptionClassTypes = EditorTools.GetAssignableTypes(typeof(IEncryptionServices));
|
||||
var classType = encryptionClassTypes.Find(x => x.FullName != null && x.FullName.Equals(encryptionClassName));
|
||||
if (classType != null)
|
||||
@@ -310,7 +223,7 @@ namespace TEngine
|
||||
|
||||
public static void BuildImp(BuildTargetGroup buildTargetGroup, BuildTarget buildTarget, string locationPathName)
|
||||
{
|
||||
EditorUserBuildSettings.SwitchActiveBuildTarget(buildTargetGroup, buildTarget);
|
||||
EditorUserBuildSettings.SwitchActiveBuildTarget(buildTargetGroup, BuildTarget.StandaloneWindows64);
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions
|
||||
|
@@ -7,9 +7,7 @@
|
||||
"GUID:4d1926c9df5b052469a1c63448b7609a",
|
||||
"GUID:6e76b07590314a543b982daed6af2509",
|
||||
"GUID:2373f786d14518f44b0f475db77ba4de",
|
||||
"GUID:6055be8ebefd69e48b49212b09b47b2f",
|
||||
"GUID:3743e71edcd5bd8499007797ef02cbfb",
|
||||
"GUID:66e09fc524ec6594b8d6ca1d91aa1a41"
|
||||
"GUID:6055be8ebefd69e48b49212b09b47b2f"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
|
@@ -535,7 +535,7 @@ namespace TEngine
|
||||
/// <typeparam name="TArg4">事件参数4类型。</typeparam>
|
||||
public static void Send<TArg1, TArg2, TArg3, TArg4>(string eventType, TArg1 arg1, TArg2 arg2, TArg3 arg3, TArg4 arg4)
|
||||
{
|
||||
_eventMgr.Dispatcher.Send(RuntimeId.ToRuntimeId(eventType), arg1, arg2, arg3, arg4);
|
||||
_eventMgr.Dispatcher.Send(RuntimeId.ToRuntimeId(eventType), arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@@ -36,16 +36,6 @@ namespace TEngine
|
||||
/// </summary>
|
||||
NoNotice = 2,
|
||||
}
|
||||
/// <summary>
|
||||
/// WebGL平台下,
|
||||
/// StreamingAssets:跳过远程下载资源直接访问StreamingAssets
|
||||
/// Remote:访问远程资源
|
||||
/// </summary>
|
||||
public enum LoadResWayWebGL
|
||||
{
|
||||
Remote,
|
||||
StreamingAssets,
|
||||
}
|
||||
|
||||
[CreateAssetMenu(menuName = "TEngine/UpdateSetting", fileName = "UpdateSetting")]
|
||||
public class UpdateSetting : ScriptableObject
|
||||
@@ -106,48 +96,6 @@ namespace TEngine
|
||||
[SerializeField]
|
||||
private string FallbackResDownLoadPath = "http://127.0.0.1:8082";
|
||||
|
||||
/// <summary>
|
||||
/// WebGL平台加载本地资源/加载远程资源。
|
||||
/// </summary>
|
||||
[Header("WebGL设置")]
|
||||
[SerializeField]
|
||||
private LoadResWayWebGL LoadResWayWebGL = LoadResWayWebGL.Remote;
|
||||
/// <summary>
|
||||
/// 是否自动你讲打包资源复制到打包后的StreamingAssets地址
|
||||
/// </summary>
|
||||
[Header("构建资源设置")]
|
||||
[SerializeField]
|
||||
private bool isAutoAssetCopeToBuildAddress = false;
|
||||
/// <summary>
|
||||
/// 打包程序资源地址
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
private string BuildAddress = "../../Builds/Unity_Data/StreamingAssets";
|
||||
/// <summary>
|
||||
/// 是否自动你讲打包资源复制到打包后的StreamingAssets地址
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsAutoAssetCopeToBuildAddress()
|
||||
{
|
||||
return isAutoAssetCopeToBuildAddress;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取打包程序资源地址
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetBuildAddress()
|
||||
{
|
||||
return BuildAddress;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否加载远程资源
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public LoadResWayWebGL GetLoadResWayWebGL()
|
||||
{
|
||||
return LoadResWayWebGL;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取资源下载路径。
|
||||
/// </summary>
|
||||
|
@@ -205,8 +205,7 @@ namespace TEngine
|
||||
|
||||
public long Color(UnityEngine.SpriteRenderer target, UnityEngine.Color startValue, UnityEngine.Color endValue, float duration, Ease ease = Ease.Default, int cycles = 1,
|
||||
CycleMode cycleMode = CycleMode.Restart, float startDelay = 0, float endDelay = 0, bool useUnscaledTime = false);
|
||||
public long MaterialColor(UnityEngine.Material target, UnityEngine.Color startValue, UnityEngine.Color endValue, float duration, Ease ease = Ease.Default, int cycles = 1,
|
||||
CycleMode cycleMode = CycleMode.Restart, float startDelay = 0, float endDelay = 0, bool useUnscaledTime = false);
|
||||
|
||||
public long Alpha(UnityEngine.SpriteRenderer target, Single endValue, float duration, Ease ease = Ease.Default, int cycles = 1, CycleMode cycleMode = CycleMode.Restart,
|
||||
float startDelay = 0, float endDelay = 0, bool useUnscaledTime = false);
|
||||
|
||||
|
@@ -486,16 +486,7 @@ namespace TEngine
|
||||
return _tweenHelper.Color(target, startValue, endValue, duration, ease, cycles, cycleMode, startDelay, endDelay, useUnscaledTime);
|
||||
}
|
||||
|
||||
public static long MaterialColor(UnityEngine.Material target, UnityEngine.Color startValue, UnityEngine.Color endValue, float duration, Ease ease = Ease.Default, int
|
||||
cycles = 1,
|
||||
CycleMode cycleMode = CycleMode.Restart, float startDelay = 0, float endDelay = 0, bool useUnscaledTime = false)
|
||||
{
|
||||
if (_tweenHelper == null)
|
||||
{
|
||||
throw new GameFrameworkException("ITweenHelper is invalid.");
|
||||
}
|
||||
return _tweenHelper.MaterialColor(target, startValue, endValue, duration, ease, cycles, cycleMode, startDelay, endDelay, useUnscaledTime);
|
||||
}
|
||||
|
||||
public static long Alpha(UnityEngine.SpriteRenderer target, Single endValue, float duration, Ease ease = Ease.Default, int cycles = 1, CycleMode cycleMode = CycleMode.Restart,
|
||||
float startDelay = 0, float endDelay = 0, bool useUnscaledTime = false)
|
||||
{
|
||||
|
@@ -1,87 +0,0 @@
|
||||
using System.Globalization;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TEngine
|
||||
{
|
||||
public sealed partial class Debugger
|
||||
{
|
||||
private sealed class ObjectPoolInformationWindow : ScrollableDebuggerWindowBase
|
||||
{
|
||||
private IObjectPoolModule _objectPool = null;
|
||||
|
||||
public override void Initialize(params object[] args)
|
||||
{
|
||||
_objectPool = ModuleSystem.GetModule<IObjectPoolModule>();
|
||||
if (_objectPool == null)
|
||||
{
|
||||
Log.Fatal("Object pool component is invalid.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDrawScrollableWindow()
|
||||
{
|
||||
GUILayout.Label("<b>Object Pool Information</b>");
|
||||
GUILayout.BeginVertical("box");
|
||||
{
|
||||
DrawItem("Object Pool Count", _objectPool.Count.ToString());
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
ObjectPoolBase[] objectPools = _objectPool.GetAllObjectPools(true);
|
||||
for (int i = 0; i < objectPools.Length; i++)
|
||||
{
|
||||
DrawObjectPool(objectPools[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawObjectPool(ObjectPoolBase objectPool)
|
||||
{
|
||||
GUILayout.Label(Utility.Text.Format("<b>Object Pool: {0}</b>", objectPool.FullName));
|
||||
GUILayout.BeginVertical("box");
|
||||
{
|
||||
DrawItem("Name", objectPool.Name);
|
||||
DrawItem("Type", objectPool.ObjectType.FullName);
|
||||
DrawItem("Auto Release Interval", objectPool.AutoReleaseInterval.ToString(CultureInfo.InvariantCulture));
|
||||
DrawItem("Capacity", objectPool.Capacity.ToString());
|
||||
DrawItem("Used Count", objectPool.Count.ToString());
|
||||
DrawItem("Can Release Count", objectPool.CanReleaseCount.ToString());
|
||||
DrawItem("Expire Time", objectPool.ExpireTime.ToString(CultureInfo.InvariantCulture));
|
||||
DrawItem("Priority", objectPool.Priority.ToString());
|
||||
ObjectInfo[] objectInfos = objectPool.GetAllObjectInfos();
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Label("<b>Name</b>");
|
||||
GUILayout.Label("<b>Locked</b>", GUILayout.Width(60f));
|
||||
GUILayout.Label(objectPool.AllowMultiSpawn ? "<b>Count</b>" : "<b>In Use</b>", GUILayout.Width(60f));
|
||||
GUILayout.Label("<b>Flag</b>", GUILayout.Width(60f));
|
||||
GUILayout.Label("<b>Priority</b>", GUILayout.Width(60f));
|
||||
GUILayout.Label("<b>Last Use Time</b>", GUILayout.Width(120f));
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
if (objectInfos.Length > 0)
|
||||
{
|
||||
for (int i = 0; i < objectInfos.Length; i++)
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Label(string.IsNullOrEmpty(objectInfos[i].Name) ? "<None>" : objectInfos[i].Name);
|
||||
GUILayout.Label(objectInfos[i].Locked.ToString(), GUILayout.Width(60f));
|
||||
GUILayout.Label(objectPool.AllowMultiSpawn ? objectInfos[i].SpawnCount.ToString() : objectInfos[i].IsInUse.ToString(), GUILayout.Width(60f));
|
||||
GUILayout.Label(objectInfos[i].CustomCanReleaseFlag.ToString(), GUILayout.Width(60f));
|
||||
GUILayout.Label(objectInfos[i].Priority.ToString(), GUILayout.Width(60f));
|
||||
GUILayout.Label(objectInfos[i].LastUseTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"), GUILayout.Width(120f));
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GUILayout.Label("<i>Object Pool is Empty ...</i>");
|
||||
}
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 14e7f9db9d50d314186ed2e6ab3415fa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -77,7 +77,6 @@ namespace TEngine
|
||||
private RuntimeMemoryInformationWindow<Font> _runtimeMemoryFontInformationWindow = new RuntimeMemoryInformationWindow<Font>();
|
||||
private RuntimeMemoryInformationWindow<TextAsset> _runtimeMemoryTextAssetInformationWindow = new RuntimeMemoryInformationWindow<TextAsset>();
|
||||
private RuntimeMemoryInformationWindow<ScriptableObject> _runtimeMemoryScriptableObjectInformationWindow = new RuntimeMemoryInformationWindow<ScriptableObject>();
|
||||
private ObjectPoolInformationWindow _objectPoolInformationWindow = new ObjectPoolInformationWindow();
|
||||
private MemoryPoolPoolInformationWindow _memoryPoolPoolInformationWindow = new MemoryPoolPoolInformationWindow();
|
||||
private SettingsWindow _settingsWindow = new SettingsWindow();
|
||||
|
||||
@@ -210,7 +209,6 @@ namespace TEngine
|
||||
RegisterDebuggerWindow("Profiler/Memory/Font", _runtimeMemoryFontInformationWindow);
|
||||
RegisterDebuggerWindow("Profiler/Memory/TextAsset", _runtimeMemoryTextAssetInformationWindow);
|
||||
RegisterDebuggerWindow("Profiler/Memory/ScriptableObject", _runtimeMemoryScriptableObjectInformationWindow);
|
||||
RegisterDebuggerWindow("Profiler/Object Pool", _objectPoolInformationWindow);;
|
||||
RegisterDebuggerWindow("Profiler/Reference Pool", _memoryPoolPoolInformationWindow);
|
||||
RegisterDebuggerWindow("Other/Settings", _settingsWindow);
|
||||
|
||||
|
@@ -3,7 +3,6 @@ using Cysharp.Threading.Tasks;
|
||||
using TEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System;
|
||||
|
||||
public static class SetSpriteExtensions
|
||||
{
|
||||
@@ -13,11 +12,10 @@ public static class SetSpriteExtensions
|
||||
/// <param name="image">UI/Image。</param>
|
||||
/// <param name="location">资源定位地址。</param>
|
||||
/// <param name="setNativeSize">是否使用原始分辨率。</param>
|
||||
/// <param name="callback">设置完Sprite的回调</param>
|
||||
/// <param name="cancellationToken">取消设置资源的Token。</param>
|
||||
public static void SetSprite(this Image image, string location, bool setNativeSize = false, Action<Image> callback = null, CancellationToken cancellationToken = default)
|
||||
public static void SetSprite(this Image image, string location, bool setNativeSize = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
ResourceExtComponent.Instance.SetAssetByResources<Sprite>(SetSpriteObject.Create(image, location, setNativeSize, callback, cancellationToken)).Forget();
|
||||
ResourceExtComponent.Instance.SetAssetByResources<Sprite>(SetSpriteObject.Create(image, location, setNativeSize, cancellationToken)).Forget();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -25,11 +23,10 @@ public static class SetSpriteExtensions
|
||||
/// </summary>
|
||||
/// <param name="spriteRenderer">2D/SpriteRender。</param>
|
||||
/// <param name="location">资源定位地址。</param>
|
||||
/// <param name="callback">设置完Sprite的回调</param>
|
||||
/// <param name="cancellationToken">取消设置资源的Token。</param>
|
||||
public static void SetSprite(this SpriteRenderer spriteRenderer, string location, Action<SpriteRenderer> callback = null, CancellationToken cancellationToken = default)
|
||||
public static void SetSprite(this SpriteRenderer spriteRenderer, string location, CancellationToken cancellationToken = default)
|
||||
{
|
||||
ResourceExtComponent.Instance.SetAssetByResources<Sprite>(SetSpriteObject.Create(spriteRenderer, location, callback, cancellationToken)).Forget();
|
||||
ResourceExtComponent.Instance.SetAssetByResources<Sprite>(SetSpriteObject.Create(spriteRenderer, location, cancellationToken)).Forget();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@@ -41,8 +41,6 @@ namespace TEngine
|
||||
public string Location { get; private set; }
|
||||
|
||||
private bool _setNativeSize = false;
|
||||
Action<Image> _imageCallback;
|
||||
Action<SpriteRenderer> _spriteCallback;
|
||||
|
||||
private CancellationToken _cancellationToken;
|
||||
|
||||
@@ -60,12 +58,10 @@ namespace TEngine
|
||||
{
|
||||
_image.SetNativeSize();
|
||||
}
|
||||
_imageCallback?.Invoke(_image);
|
||||
}
|
||||
else if (_spriteRenderer != null)
|
||||
{
|
||||
_spriteRenderer.sprite = _sprite;
|
||||
_spriteCallback?.Invoke(_spriteRenderer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +90,7 @@ namespace TEngine
|
||||
_setNativeSize = false;
|
||||
}
|
||||
|
||||
public static SetSpriteObject Create(Image image, string location, bool setNativeSize = false, Action<Image> callback = null, CancellationToken cancellationToken = default)
|
||||
public static SetSpriteObject Create(Image image, string location, bool setNativeSize = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
SetSpriteObject item = MemoryPool.Acquire<SetSpriteObject>();
|
||||
item._image = image;
|
||||
@@ -102,18 +98,16 @@ namespace TEngine
|
||||
item.Location = location;
|
||||
item._cancellationToken = cancellationToken;
|
||||
item._setType = SetType.Image;
|
||||
item._imageCallback = callback;
|
||||
return item;
|
||||
}
|
||||
|
||||
public static SetSpriteObject Create(SpriteRenderer spriteRenderer, string location, Action<SpriteRenderer> callback = null, CancellationToken cancellationToken = default)
|
||||
public static SetSpriteObject Create(SpriteRenderer spriteRenderer, string location, CancellationToken cancellationToken = default)
|
||||
{
|
||||
SetSpriteObject item = MemoryPool.Acquire<SetSpriteObject>();
|
||||
item._spriteRenderer = spriteRenderer;
|
||||
item.Location = location;
|
||||
item._cancellationToken = cancellationToken;
|
||||
item._setType = SetType.SpriteRender;
|
||||
item._spriteCallback = callback;
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
@@ -55,8 +55,7 @@ namespace TEngine
|
||||
/// 初始化操作。
|
||||
/// </summary>
|
||||
/// <param name="customPackageName">资源包名称。</param>
|
||||
/// <param name="needInitMainFest">是否需要直接初始化资源清单。(单机OtherPackage使用)</param>
|
||||
UniTask<InitializationOperation> InitPackage(string customPackageName, bool needInitMainFest = false);
|
||||
UniTask<InitializationOperation> InitPackage(string customPackageName);
|
||||
|
||||
/// <summary>
|
||||
/// 默认资源包名称。
|
||||
@@ -78,11 +77,6 @@ namespace TEngine
|
||||
/// </summary>
|
||||
string FallbackHostServerURL { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// WebGL平台加载本地资源/加载远程资源。
|
||||
/// </summary>
|
||||
LoadResWayWebGL LoadResWayWebGL { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置资源对象池自动释放可释放对象的间隔秒数。
|
||||
/// </summary>
|
||||
|
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace TEngine
|
||||
@@ -19,7 +20,6 @@ namespace TEngine
|
||||
}
|
||||
}
|
||||
|
||||
[DisallowMultipleComponent]
|
||||
public sealed class AssetsReference : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
@@ -28,18 +28,11 @@ namespace TEngine
|
||||
[SerializeField]
|
||||
private List<AssetsRefInfo> refAssetInfoList;
|
||||
|
||||
private static IResourceModule _resourceModule;
|
||||
private IResourceModule _resourceModule;
|
||||
|
||||
private static Dictionary<GameObject, AssetsReference> _originalRefs = new();
|
||||
|
||||
|
||||
private void CheckInit()
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (_resourceModule != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
if (_resourceModule == null)
|
||||
{
|
||||
_resourceModule = ModuleSystem.GetModule<IResourceModule>();
|
||||
}
|
||||
@@ -48,49 +41,11 @@ namespace TEngine
|
||||
{
|
||||
throw new GameFrameworkException($"resourceModule is null.");
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckRelease()
|
||||
{
|
||||
if (sourceGameObject != null)
|
||||
{
|
||||
_resourceModule.UnloadAsset(sourceGameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Warning($"sourceGameObject is not invalid.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
// If it is a clone, clear the reference records before cloning
|
||||
if (!IsOriginalInstance())
|
||||
{
|
||||
ClearCloneReferences();
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsOriginalInstance()
|
||||
{
|
||||
return _originalRefs.TryGetValue(gameObject, out var originalComponent) &&
|
||||
originalComponent == this;
|
||||
}
|
||||
|
||||
private void ClearCloneReferences()
|
||||
{
|
||||
sourceGameObject = null;
|
||||
refAssetInfoList?.Clear();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
CheckInit();
|
||||
if (sourceGameObject != null)
|
||||
{
|
||||
CheckRelease();
|
||||
}
|
||||
|
||||
ReleaseRefAssetInfoList();
|
||||
}
|
||||
@@ -122,16 +77,10 @@ namespace TEngine
|
||||
|
||||
_resourceModule = resourceModule;
|
||||
sourceGameObject = source;
|
||||
|
||||
if (!_originalRefs.ContainsKey(gameObject))
|
||||
{
|
||||
_originalRefs.Add(gameObject, this);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public AssetsReference Ref<T>(T source, IResourceModule resourceModule = null) where T : Object
|
||||
public AssetsReference Ref<T>(T source, IResourceModule resourceModule = null) where T : UnityEngine.Object
|
||||
{
|
||||
if (source == null)
|
||||
{
|
||||
@@ -148,7 +97,7 @@ namespace TEngine
|
||||
return this;
|
||||
}
|
||||
|
||||
internal static AssetsReference Instantiate(GameObject source, Transform parent = null, IResourceModule resourceModule = null)
|
||||
public static AssetsReference Instantiate(GameObject source, Transform parent = null, IResourceModule resourceModule = null)
|
||||
{
|
||||
if (source == null)
|
||||
{
|
||||
@@ -177,10 +126,10 @@ namespace TEngine
|
||||
}
|
||||
|
||||
var comp = instance.GetComponent<AssetsReference>();
|
||||
return comp ? comp.Ref(source, resourceModule) : instance.AddComponent<AssetsReference>().Ref(source, resourceModule);
|
||||
return comp ? comp : instance.AddComponent<AssetsReference>().Ref(source, resourceModule);
|
||||
}
|
||||
|
||||
public static AssetsReference Ref<T>(T source, GameObject instance, IResourceModule resourceModule = null) where T : Object
|
||||
public static AssetsReference Ref<T>(T source, GameObject instance, IResourceModule resourceModule = null) where T : UnityEngine.Object
|
||||
{
|
||||
if (source == null)
|
||||
{
|
||||
@@ -188,7 +137,7 @@ namespace TEngine
|
||||
}
|
||||
|
||||
var comp = instance.GetComponent<AssetsReference>();
|
||||
return comp ? comp.Ref(source, resourceModule) : instance.AddComponent<AssetsReference>().Ref(source, resourceModule);
|
||||
return comp ? comp : instance.AddComponent<AssetsReference>().Ref(source, resourceModule);
|
||||
}
|
||||
}
|
||||
}
|
@@ -86,14 +86,6 @@ namespace TEngine
|
||||
return decryptResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 后备方式获取解密的资源包对象
|
||||
/// </summary>
|
||||
DecryptResult IDecryptionServices.LoadAssetBundleFallback(DecryptFileInfo fileInfo)
|
||||
{
|
||||
return new DecryptResult();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取解密的字节数据
|
||||
/// </summary>
|
||||
@@ -166,14 +158,6 @@ namespace TEngine
|
||||
return decryptResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 后备方式获取解密的资源包对象
|
||||
/// </summary>
|
||||
DecryptResult IDecryptionServices.LoadAssetBundleFallback(DecryptFileInfo fileInfo)
|
||||
{
|
||||
return new DecryptResult();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取解密的字节数据
|
||||
/// </summary>
|
||||
|
@@ -54,11 +54,6 @@ namespace TEngine
|
||||
|
||||
public string FallbackHostServerURL { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// WebGL:加载资源方式
|
||||
/// </summary>
|
||||
public LoadResWayWebGL LoadResWayWebGL { get; set; }
|
||||
|
||||
private string _applicableGameVersion;
|
||||
|
||||
private int _internalResourceVersion;
|
||||
@@ -131,7 +126,7 @@ namespace TEngine
|
||||
SetObjectPoolModule(objectPoolManager);
|
||||
}
|
||||
|
||||
public async UniTask<InitializationOperation> InitPackage(string packageName, bool needInitMainFest = false)
|
||||
public async UniTask<InitializationOperation> InitPackage(string packageName)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
//编辑器模式使用。
|
||||
@@ -212,10 +207,7 @@ namespace TEngine
|
||||
createParameters.WebServerFileSystemParameters = WechatFileSystemCreater.CreateFileSystemParameters(packageRoot, remoteServices, webDecryptionServices);
|
||||
#else
|
||||
Log.Info("=======================UNITY_WEBGL=======================");
|
||||
if (LoadResWayWebGL==LoadResWayWebGL.Remote)
|
||||
{
|
||||
createParameters.WebRemoteFileSystemParameters = FileSystemParameters.CreateDefaultWebRemoteFileSystemParameters(remoteServices, webDecryptionServices);
|
||||
}
|
||||
createParameters.WebRemoteFileSystemParameters = FileSystemParameters.CreateDefaultWebRemoteFileSystemParameters(remoteServices, webDecryptionServices);
|
||||
createParameters.WebServerFileSystemParameters = FileSystemParameters.CreateDefaultWebServerFileSystemParameters(webDecryptionServices);
|
||||
#endif
|
||||
initializationOperation = package.InitializeAsync(createParameters);
|
||||
@@ -225,27 +217,6 @@ namespace TEngine
|
||||
|
||||
Log.Info($"Init resource package version : {initializationOperation?.Status}");
|
||||
|
||||
if (needInitMainFest)
|
||||
{
|
||||
// 2. 请求资源清单的版本信息
|
||||
var requestPackageVersionOperation = package.RequestPackageVersionAsync();
|
||||
await requestPackageVersionOperation;
|
||||
if (requestPackageVersionOperation.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
// 3. 传入的版本信息更新资源清单
|
||||
var updatePackageManifestAsync = package.UpdatePackageManifestAsync(requestPackageVersionOperation.PackageVersion);
|
||||
await updatePackageManifestAsync;
|
||||
if (updatePackageManifestAsync.Status == EOperationStatus.Failed)
|
||||
{
|
||||
Log.Fatal($"Update package manifest failed : {updatePackageManifestAsync.Status}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Fatal($"Request package version failed : {requestPackageVersionOperation.Status}");
|
||||
}
|
||||
}
|
||||
|
||||
return initializationOperation;
|
||||
}
|
||||
|
||||
|
@@ -250,7 +250,6 @@ namespace TEngine
|
||||
_resourceModule.Milliseconds = milliseconds;
|
||||
_resourceModule.HostServerURL = Settings.UpdateSetting.GetResDownLoadPath();
|
||||
_resourceModule.FallbackHostServerURL = Settings.UpdateSetting.GetFallbackResDownLoadPath();
|
||||
_resourceModule.LoadResWayWebGL=Settings.UpdateSetting.GetLoadResWayWebGL();
|
||||
_resourceModule.DownloadingMaxNum = DownloadingMaxNum;
|
||||
_resourceModule.FailedTryAgain = FailedTryAgain;
|
||||
_resourceModule.UpdatableWhilePlaying = UpdatableWhilePlaying;
|
||||
|
@@ -71,9 +71,6 @@ namespace TEngine
|
||||
|
||||
subScene = YooAssets.LoadSceneAsync(location, sceneMode, LocalPhysicsMode.None, suspendLoad, priority);
|
||||
|
||||
//Fix 这里前置,subScene.IsDone在UnSupendLoad之后才会是true
|
||||
_subScenes.Add(location, subScene);
|
||||
|
||||
if (progressCallBack != null)
|
||||
{
|
||||
while (!subScene.IsDone && subScene.IsValid)
|
||||
@@ -87,6 +84,8 @@ namespace TEngine
|
||||
await subScene.ToUniTask();
|
||||
}
|
||||
|
||||
_subScenes.Add(location, subScene);
|
||||
|
||||
_handlingScene.Remove(location);
|
||||
|
||||
return subScene.SceneObject;
|
||||
|
@@ -47,50 +47,6 @@ MonoBehaviour:
|
||||
innerLocalizationCsv: {fileID: 0}
|
||||
allLanguage: []
|
||||
useRuntimeModule: 1
|
||||
--- !u!1 &7471325143993775112
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 5905096077013678464}
|
||||
- component: {fileID: 7968529201080193016}
|
||||
m_Layer: 0
|
||||
m_Name: Obfuz
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &5905096077013678464
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7471325143993775112}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 7696541955266276700}
|
||||
m_RootOrder: 6
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &7968529201080193016
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7471325143993775112}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 883bcac172734133a1972a05275df53b, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &7696541953913300370
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -252,7 +208,6 @@ MonoBehaviour:
|
||||
useSystemUnloadUnusedAssets: 1
|
||||
packageName: DefaultPackage
|
||||
playMode: 0
|
||||
encryptionType: 0
|
||||
updatableWhilePlaying: 0
|
||||
milliseconds: 30
|
||||
downloadingMaxNum: 10
|
||||
@@ -311,7 +266,6 @@ Transform:
|
||||
- {fileID: 7696541955235861479}
|
||||
- {fileID: 404609667950854598}
|
||||
- {fileID: 5550035055454355162}
|
||||
- {fileID: 5905096077013678464}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
|
@@ -23,7 +23,6 @@ MonoBehaviour:
|
||||
- TEngine.Runtime.dll
|
||||
- UniTask.dll
|
||||
- YooAsset.dll
|
||||
- UnityEngine.CoreModule.dll
|
||||
LogicMainDllName: GameLogic.dll
|
||||
AssemblyTextAssetExtension: .bytes
|
||||
AssemblyTextAssetPath: AssetRaw/DLL
|
||||
@@ -31,6 +30,3 @@ MonoBehaviour:
|
||||
UpdateNotice: 1
|
||||
ResDownLoadPath: http://127.0.0.1:8081
|
||||
FallbackResDownLoadPath: http://127.0.0.1:8082
|
||||
LoadResWayWebGL: 0
|
||||
isAutoAssetCopeToBuildAddress: 0
|
||||
BuildAddress: ../../Builds/Unity_Data/StreamingAssets
|
||||
|
@@ -2,141 +2,6 @@
|
||||
|
||||
All notable changes to this package will be documented in this file.
|
||||
|
||||
## [2.3.12] - 2025-07-01
|
||||
|
||||
### Improvements
|
||||
|
||||
- 优化了同步接口导致的资源拷贝和资源验证性能开销高的现象。
|
||||
- 微信小游戏和抖音小游戏支持资源清单加密。
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#579) 修复了2.3.10版本资源包构建页面里CopyBuildinFileParam无法编辑问题。
|
||||
- (#572) 修复了资源收集页面指定收集的预制体名称变动的问题。
|
||||
- (#582) 修复了非递归收集依赖时,依赖列表中才包含主资源的问题。
|
||||
|
||||
### Added
|
||||
|
||||
- 新增初始化参数:WebGLForceSyncLoadAsset
|
||||
|
||||
```csharp
|
||||
public abstract class InitializeParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// WebGL平台强制同步加载资源对象
|
||||
/// </summary>Add commentMore actions
|
||||
public bool WebGLForceSyncLoadAsset = false;
|
||||
}
|
||||
```
|
||||
|
||||
- (#576) 新增了资源清单服务类:IManifestServices
|
||||
|
||||
```csharp
|
||||
/// <summary>
|
||||
/// 资源清单文件处理服务接口
|
||||
/// </summary>
|
||||
public interface IManifestServices
|
||||
{
|
||||
/// <summary>
|
||||
/// 处理资源清单(压缩和加密)
|
||||
/// </summary>
|
||||
byte[] ProcessManifest(byte[] fileData);
|
||||
|
||||
/// <summary>
|
||||
/// 还原资源清单(解压和解密)
|
||||
/// </summary>
|
||||
byte[] RestoreManifest(byte[] fileData);
|
||||
}
|
||||
```
|
||||
|
||||
- (#585) 新增了本地文件拷贝服务类:ICopyLocalFileServices
|
||||
|
||||
```csharp
|
||||
/// <summary>
|
||||
/// 本地文件拷贝服务类
|
||||
/// </summary>
|
||||
public interface ICopyLocalFileServices
|
||||
{
|
||||
void CopyFile(LocalFileInfo sourceFileInfo, string destFilePath);
|
||||
}
|
||||
```
|
||||
|
||||
## [2.3.10] - 2025-06-17
|
||||
|
||||
### Improvements
|
||||
|
||||
- 小游戏扩展库已经独立,可以单独导入到项目工程。
|
||||
- 编辑器里的TableView视图新增了AssetObjectCell类。
|
||||
- (#552) 微信小游戏文件系统类,增加了URL合法性的初始化检测机制。
|
||||
- (#566) 重构了资源构建页面,方便扩展自定义界面。
|
||||
- (#573) 完善了AssetDependencyDB的输出日志,可以正确输出丢失的引用资产信息。
|
||||
|
||||
### Fixed
|
||||
|
||||
- 修复太空战机DEMO在退出运行模式时的报错。
|
||||
- (#551) 修复了Unity2019, Unity2020的代码兼容性报错。
|
||||
- (#569) 修复了TVOS平台的兼容问题。
|
||||
- (#564) 修复了TiktokFileSystem文件系统里appendTimeTicks无效的问题。
|
||||
|
||||
### Added
|
||||
|
||||
- (#562) 新增了解密方法。
|
||||
|
||||
```csharp
|
||||
public interface IDecryptionServices
|
||||
{
|
||||
/// <summary>
|
||||
/// 后备方式获取解密的资源包对象
|
||||
/// 注意:当正常解密方法失败后,会触发后备加载!
|
||||
/// 说明:建议通过LoadFromMemory()方法加载资源对象作为保底机制。
|
||||
/// issues : https://github.com/tuyoogame/YooAsset/issues/562
|
||||
/// </summary>
|
||||
DecryptResult LoadAssetBundleFallback(DecryptFileInfo fileInfo);
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
## [2.3.9] - 2025-05-13
|
||||
|
||||
### Improvements
|
||||
|
||||
- 增加了YOO_ASSET_EXPERIMENT宏,用于控制实验性代码的开关。
|
||||
- 构建管线目前会输出构建日志到输出目录下,方便查看引擎在构建时主动清空的控制台日志。
|
||||
- 优化了收集器tag传染扩散逻辑,避免Group里配置了Tag导致的无意义的警告信息。
|
||||
- 扩展工程内PanelMonitor代码默认关闭状态。
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#528) 修复了AssetDependencyDatabase在查询引擎资源对象是否存在的时效问题。
|
||||
|
||||
### Added
|
||||
|
||||
- (#542) 新增了资源管理系统销毁方法。
|
||||
|
||||
该方法会销毁所有的资源包裹和异步操作任务,以及卸载所有AssetBundle对象!
|
||||
|
||||
```csharp
|
||||
public class YooAssets
|
||||
{
|
||||
/// <summary>
|
||||
/// 销毁资源系统
|
||||
/// </summary>
|
||||
public static void Destroy();
|
||||
}
|
||||
```
|
||||
|
||||
- 新增了SBP构建管线的构建参数
|
||||
|
||||
```csharp
|
||||
/// <summary>
|
||||
/// 从AssetBundle文件头里剥离Unity版本信息
|
||||
/// </summary>
|
||||
public bool StripUnityVersion = false;
|
||||
```
|
||||
|
||||
- 新增了构建错误码:BuiltinShadersBundleNameIsNull
|
||||
|
||||
## [2.3.8] - 2025-04-17
|
||||
|
||||
### Improvements
|
||||
|
@@ -196,32 +196,6 @@ namespace YooAsset.Editor
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导入单个报告对象
|
||||
/// </summary>
|
||||
public void ImportSingleReprotFile(ScanReport report)
|
||||
{
|
||||
_reportCombiner = new ScanReportCombiner();
|
||||
|
||||
try
|
||||
{
|
||||
_reportCombiner.Combine(report);
|
||||
|
||||
// 刷新页面
|
||||
RefreshToolbar();
|
||||
FillTableView();
|
||||
RebuildView();
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
_reportCombiner = null;
|
||||
_titleLabel.text = "导入报告失败!";
|
||||
_descLabel.text = e.Message;
|
||||
UnityEngine.Debug.LogError(e.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void ImportSingleBtn_clicked()
|
||||
{
|
||||
string selectFilePath = EditorUtility.OpenFilePanel("导入报告", _lastestOpenFolder, "json");
|
||||
@@ -472,31 +446,15 @@ namespace YooAsset.Editor
|
||||
var column = new TableColumn(header.HeaderTitle, header.HeaderTitle, columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
if (header.HeaderType == EHeaderType.AssetObject)
|
||||
{
|
||||
var objectFiled = new ObjectField();
|
||||
return objectFiled;
|
||||
}
|
||||
else
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
}
|
||||
var label = new Label();
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
if (header.HeaderType == EHeaderType.AssetObject)
|
||||
{
|
||||
var objectFiled = element as ObjectField;
|
||||
objectFiled.value = (UnityEngine.Object)cell.GetDisplayObject();
|
||||
}
|
||||
else
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
}
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_elementTableView.AddColumn(column);
|
||||
}
|
||||
@@ -522,10 +480,6 @@ namespace YooAsset.Editor
|
||||
{
|
||||
tableData.AddAssetPathCell(scanInfo.HeaderTitle, scanInfo.ScanInfo);
|
||||
}
|
||||
else if (header.HeaderType == EHeaderType.AssetObject)
|
||||
{
|
||||
tableData.AddAssetObjectCell(scanInfo.HeaderTitle, scanInfo.ScanInfo);
|
||||
}
|
||||
else if (header.HeaderType == EHeaderType.StringValue)
|
||||
{
|
||||
tableData.AddStringValueCell(scanInfo.HeaderTitle, scanInfo.ScanInfo);
|
||||
|
@@ -8,11 +8,6 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
AssetPath,
|
||||
|
||||
/// <summary>
|
||||
/// 资源对象
|
||||
/// </summary>
|
||||
AssetObject,
|
||||
|
||||
/// <summary>
|
||||
/// 字符串
|
||||
/// </summary>
|
||||
|
@@ -126,12 +126,6 @@ namespace YooAsset.Editor
|
||||
if (string.IsNullOrEmpty(guid))
|
||||
throw new Exception($"{HeaderTitle} value is invalid asset path : {value}");
|
||||
}
|
||||
else if (HeaderType == EHeaderType.AssetObject)
|
||||
{
|
||||
string guid = AssetDatabase.AssetPathToGUID(value);
|
||||
if (string.IsNullOrEmpty(guid))
|
||||
throw new Exception($"{HeaderTitle} value is invalid asset object : {value}");
|
||||
}
|
||||
else if (HeaderType == EHeaderType.DoubleValue)
|
||||
{
|
||||
if (double.TryParse(value, out double doubleValue) == false)
|
||||
|
@@ -46,7 +46,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new ScannerResult(e.StackTrace);
|
||||
return new ScannerResult(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -52,7 +52,7 @@ namespace YooAsset.Editor
|
||||
if (Succeed)
|
||||
{
|
||||
var reproterWindow = AssetArtReporterWindow.OpenWindow();
|
||||
reproterWindow.ImportSingleReprotFile(Report);
|
||||
reproterWindow.ImportSingleReprotFile(ReprotFilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -6,110 +6,97 @@ namespace YooAsset.Editor
|
||||
{
|
||||
public static class AssetBundleBuilderSetting
|
||||
{
|
||||
// BuildPipelineName
|
||||
public static string GetPackageBuildPipeline(string packageName)
|
||||
// EBuildPipeline
|
||||
public static EBuildPipeline GetPackageBuildPipeline(string packageName)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_BuildPipelineName";
|
||||
string defaultValue = EBuildPipeline.ScriptableBuildPipeline.ToString();
|
||||
return EditorPrefs.GetString(key, defaultValue);
|
||||
string key = $"{Application.productName}_{packageName}_{nameof(EBuildPipeline)}";
|
||||
return (EBuildPipeline)EditorPrefs.GetInt(key, (int)EBuildPipeline.BuiltinBuildPipeline);
|
||||
}
|
||||
public static void SetPackageBuildPipeline(string packageName, string buildPipeline)
|
||||
public static void SetPackageBuildPipeline(string packageName, EBuildPipeline buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_BuildPipelineName";
|
||||
EditorPrefs.SetString(key, buildPipeline);
|
||||
string key = $"{Application.productName}_{packageName}_{nameof(EBuildPipeline)}";
|
||||
EditorPrefs.SetInt(key, (int)buildPipeline);
|
||||
}
|
||||
|
||||
// ECompressOption
|
||||
public static ECompressOption GetPackageCompressOption(string packageName, string buildPipeline)
|
||||
public static ECompressOption GetPackageCompressOption(string packageName, EBuildPipeline buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(ECompressOption)}";
|
||||
return (ECompressOption)EditorPrefs.GetInt(key, (int)ECompressOption.LZ4);
|
||||
}
|
||||
public static void SetPackageCompressOption(string packageName, string buildPipeline, ECompressOption compressOption)
|
||||
public static void SetPackageCompressOption(string packageName, EBuildPipeline buildPipeline, ECompressOption compressOption)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(ECompressOption)}";
|
||||
EditorPrefs.SetInt(key, (int)compressOption);
|
||||
}
|
||||
|
||||
// EFileNameStyle
|
||||
public static EFileNameStyle GetPackageFileNameStyle(string packageName, string buildPipeline)
|
||||
public static EFileNameStyle GetPackageFileNameStyle(string packageName, EBuildPipeline buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EFileNameStyle)}";
|
||||
return (EFileNameStyle)EditorPrefs.GetInt(key, (int)EFileNameStyle.HashName);
|
||||
}
|
||||
public static void SetPackageFileNameStyle(string packageName, string buildPipeline, EFileNameStyle fileNameStyle)
|
||||
public static void SetPackageFileNameStyle(string packageName, EBuildPipeline buildPipeline, EFileNameStyle fileNameStyle)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EFileNameStyle)}";
|
||||
EditorPrefs.SetInt(key, (int)fileNameStyle);
|
||||
}
|
||||
|
||||
// EBuildinFileCopyOption
|
||||
public static EBuildinFileCopyOption GetPackageBuildinFileCopyOption(string packageName, string buildPipeline)
|
||||
public static EBuildinFileCopyOption GetPackageBuildinFileCopyOption(string packageName, EBuildPipeline buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildinFileCopyOption)}";
|
||||
return (EBuildinFileCopyOption)EditorPrefs.GetInt(key, (int)EBuildinFileCopyOption.None);
|
||||
}
|
||||
public static void SetPackageBuildinFileCopyOption(string packageName, string buildPipeline, EBuildinFileCopyOption buildinFileCopyOption)
|
||||
public static void SetPackageBuildinFileCopyOption(string packageName, EBuildPipeline buildPipeline, EBuildinFileCopyOption buildinFileCopyOption)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildinFileCopyOption)}";
|
||||
EditorPrefs.SetInt(key, (int)buildinFileCopyOption);
|
||||
}
|
||||
|
||||
// BuildFileCopyParams
|
||||
public static string GetPackageBuildinFileCopyParams(string packageName, string buildPipeline)
|
||||
public static string GetPackageBuildinFileCopyParams(string packageName, EBuildPipeline buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_BuildFileCopyParams";
|
||||
return EditorPrefs.GetString(key, string.Empty);
|
||||
}
|
||||
public static void SetPackageBuildinFileCopyParams(string packageName, string buildPipeline, string buildinFileCopyParams)
|
||||
public static void SetPackageBuildinFileCopyParams(string packageName, EBuildPipeline buildPipeline, string buildinFileCopyParams)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_BuildFileCopyParams";
|
||||
EditorPrefs.SetString(key, buildinFileCopyParams);
|
||||
}
|
||||
|
||||
// EncyptionServicesClassName
|
||||
public static string GetPackageEncyptionServicesClassName(string packageName, string buildPipeline)
|
||||
// EncyptionClassName
|
||||
public static string GetPackageEncyptionClassName(string packageName, EBuildPipeline buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_EncyptionServicesClassName";
|
||||
return EditorPrefs.GetString(key, $"{typeof(EncryptionNone).FullName}");
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_EncyptionClassName";
|
||||
return EditorPrefs.GetString(key, string.Empty);
|
||||
}
|
||||
public static void SetPackageEncyptionServicesClassName(string packageName, string buildPipeline, string encyptionClassName)
|
||||
public static void SetPackageEncyptionClassName(string packageName, EBuildPipeline buildPipeline, string encyptionClassName)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_EncyptionServicesClassName";
|
||||
EditorPrefs.SetString(key, encyptionClassName);
|
||||
}
|
||||
|
||||
// ManifestServicesClassName
|
||||
public static string GetPackageManifestServicesClassName(string packageName, string buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_ManifestServicesClassName";
|
||||
return EditorPrefs.GetString(key, $"{typeof(ManifestNone).FullName}");
|
||||
}
|
||||
public static void SetPackageManifestServicesClassName(string packageName, string buildPipeline, string encyptionClassName)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_ManifestServicesClassName";
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_EncyptionClassName";
|
||||
EditorPrefs.SetString(key, encyptionClassName);
|
||||
}
|
||||
|
||||
// ClearBuildCache
|
||||
public static bool GetPackageClearBuildCache(string packageName, string buildPipeline)
|
||||
public static bool GetPackageClearBuildCache(string packageName, EBuildPipeline buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_ClearBuildCache";
|
||||
return EditorPrefs.GetInt(key, 0) > 0;
|
||||
}
|
||||
public static void SetPackageClearBuildCache(string packageName, string buildPipeline, bool clearBuildCache)
|
||||
public static void SetPackageClearBuildCache(string packageName, EBuildPipeline buildPipeline, bool clearBuildCache)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_ClearBuildCache";
|
||||
EditorPrefs.SetInt(key, clearBuildCache ? 1 : 0);
|
||||
}
|
||||
|
||||
// UseAssetDependencyDB
|
||||
public static bool GetPackageUseAssetDependencyDB(string packageName, string buildPipeline)
|
||||
public static bool GetPackageUseAssetDependencyDB(string packageName, EBuildPipeline buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_UseAssetDependencyDB";
|
||||
return EditorPrefs.GetInt(key, 0) > 0;
|
||||
}
|
||||
public static void SetPackageUseAssetDependencyDB(string packageName, string buildPipeline, bool useAssetDependencyDB)
|
||||
public static void SetPackageUseAssetDependencyDB(string packageName, EBuildPipeline buildPipeline, bool useAssetDependencyDB)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_UseAssetDependencyDB";
|
||||
EditorPrefs.SetInt(key, useAssetDependencyDB ? 1 : 0);
|
||||
|
@@ -19,9 +19,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
private string _buildPackage;
|
||||
private string _buildPipeline;
|
||||
|
||||
private Dictionary<string, Type> _viewClassDic = new Dictionary<string, Type>(10);
|
||||
private EBuildPipeline _buildPipeline;
|
||||
|
||||
private Toolbar _toolbar;
|
||||
private ToolbarMenu _packageMenu;
|
||||
@@ -71,23 +69,11 @@ namespace YooAsset.Editor
|
||||
{
|
||||
_pipelineMenu = new ToolbarMenu();
|
||||
_pipelineMenu.style.width = 200;
|
||||
_pipelineMenu.menu.AppendAction(EBuildPipeline.EditorSimulateBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.EditorSimulateBuildPipeline);
|
||||
_pipelineMenu.menu.AppendAction(EBuildPipeline.BuiltinBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.BuiltinBuildPipeline);
|
||||
_pipelineMenu.menu.AppendAction(EBuildPipeline.ScriptableBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.ScriptableBuildPipeline);
|
||||
_pipelineMenu.menu.AppendAction(EBuildPipeline.RawFileBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.RawFileBuildPipeline);
|
||||
_toolbar.Add(_pipelineMenu);
|
||||
|
||||
var viewerClassTypes = EditorTools.GetAssignableTypes(typeof(BuildPipelineViewerBase));
|
||||
foreach (var classType in viewerClassTypes)
|
||||
{
|
||||
var buildPipelineAttribute = EditorTools.GetAttribute<BuildPipelineAttribute>(classType);
|
||||
string pipelineName = buildPipelineAttribute.PipelineName;
|
||||
if (_viewClassDic.ContainsKey(pipelineName))
|
||||
{
|
||||
Debug.LogWarning($"The pipeline has already exist : {pipelineName}");
|
||||
}
|
||||
else
|
||||
{
|
||||
_viewClassDic.Add(pipelineName, classType);
|
||||
_pipelineMenu.menu.AppendAction(pipelineName, PipelineMenuAction, PipelineMenuFun);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RefreshBuildPipelineView();
|
||||
@@ -105,18 +91,28 @@ namespace YooAsset.Editor
|
||||
|
||||
_buildPipeline = AssetBundleBuilderSetting.GetPackageBuildPipeline(_buildPackage);
|
||||
_packageMenu.text = _buildPackage;
|
||||
_pipelineMenu.text = _buildPipeline;
|
||||
_pipelineMenu.text = _buildPipeline.ToString();
|
||||
|
||||
if (_viewClassDic.TryGetValue(_buildPipeline, out Type value))
|
||||
var buildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||
if (_buildPipeline == EBuildPipeline.EditorSimulateBuildPipeline)
|
||||
{
|
||||
var buildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||
var viewer = Activator.CreateInstance(value) as BuildPipelineViewerBase;
|
||||
viewer.InitView(_buildPackage, _buildPipeline, buildTarget);
|
||||
viewer.CreateView(_container);
|
||||
var viewer = new EditorSimulateBuildPipelineViewer(_buildPackage, buildTarget, _container);
|
||||
}
|
||||
else if (_buildPipeline == EBuildPipeline.BuiltinBuildPipeline)
|
||||
{
|
||||
var viewer = new BuiltinBuildPipelineViewer(_buildPackage, buildTarget, _container);
|
||||
}
|
||||
else if (_buildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||
{
|
||||
var viewer = new ScriptableBuildPipelineViewer(_buildPackage, buildTarget, _container);
|
||||
}
|
||||
else if (_buildPipeline == EBuildPipeline.RawFileBuildPipeline)
|
||||
{
|
||||
var viewer = new RawfileBuildpipelineViewer(_buildPackage, buildTarget, _container);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"Not found build pipeline : {_buildPipeline}");
|
||||
throw new System.NotImplementedException(_buildPipeline.ToString());
|
||||
}
|
||||
}
|
||||
private List<string> GetBuildPackageNames()
|
||||
@@ -149,16 +145,18 @@ namespace YooAsset.Editor
|
||||
|
||||
private void PipelineMenuAction(DropdownMenuAction action)
|
||||
{
|
||||
if (_buildPipeline != action.name)
|
||||
var pipelineType = (EBuildPipeline)action.userData;
|
||||
if (_buildPipeline != pipelineType)
|
||||
{
|
||||
_buildPipeline = action.name;
|
||||
AssetBundleBuilderSetting.SetPackageBuildPipeline(_buildPackage, _buildPipeline);
|
||||
_buildPipeline = pipelineType;
|
||||
AssetBundleBuilderSetting.SetPackageBuildPipeline(_buildPackage, pipelineType);
|
||||
RefreshBuildPipelineView();
|
||||
}
|
||||
}
|
||||
private DropdownMenuAction.Status PipelineMenuFun(DropdownMenuAction action)
|
||||
{
|
||||
if (_buildPipeline == action.name)
|
||||
var pipelineType = (EBuildPipeline)action.userData;
|
||||
if (_buildPipeline == pipelineType)
|
||||
return DropdownMenuAction.Status.Checked;
|
||||
else
|
||||
return DropdownMenuAction.Status.Normal;
|
||||
|
@@ -98,11 +98,6 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public IEncryptionServices EncryptionServices;
|
||||
|
||||
/// <summary>
|
||||
/// 资源清单服务类
|
||||
/// </summary>
|
||||
public IManifestServices ManifestServices;
|
||||
|
||||
|
||||
private string _pipelineOutputDirectory = string.Empty;
|
||||
private string _packageOutputDirectory = string.Empty;
|
||||
|
@@ -14,8 +14,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
string buildinRootDirectory = buildParametersContext.GetBuildinRootDirectory();
|
||||
string buildPackageName = buildParametersContext.Parameters.PackageName;
|
||||
var manifestServices = buildParametersContext.Parameters.ManifestServices;
|
||||
DefaultBuildinFileSystemBuild.CreateBuildinCatalogFile(manifestServices, buildPackageName, buildinRootDirectory);
|
||||
DefaultBuildinFileSystemBuild.CreateBuildinCatalogFile(buildPackageName, buildinRootDirectory);
|
||||
|
||||
// 刷新目录
|
||||
AssetDatabase.Refresh();
|
||||
|
@@ -58,7 +58,7 @@ namespace YooAsset.Editor
|
||||
if (processBundleDepends)
|
||||
ProcessBuiltinBundleDependency(context, manifest);
|
||||
|
||||
// 创建资源清单文本文件
|
||||
// 创建补丁清单文本文件
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetManifestJsonFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
@@ -66,18 +66,18 @@ namespace YooAsset.Editor
|
||||
BuildLogger.Log($"Create package manifest file: {filePath}");
|
||||
}
|
||||
|
||||
// 创建资源清单二进制文件
|
||||
// 创建补丁清单二进制文件
|
||||
string packageHash;
|
||||
string packagePath;
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
packagePath = $"{packageOutputDirectory}/{fileName}";
|
||||
ManifestTools.SerializeToBinary(packagePath, manifest, buildParameters.ManifestServices);
|
||||
ManifestTools.SerializeToBinary(packagePath, manifest);
|
||||
packageHash = HashUtility.FileCRC32(packagePath);
|
||||
BuildLogger.Log($"Create package manifest file: {packagePath}");
|
||||
}
|
||||
|
||||
// 创建资源清单哈希文件
|
||||
// 创建补丁清单哈希文件
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageHashFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
@@ -85,7 +85,7 @@ namespace YooAsset.Editor
|
||||
BuildLogger.Log($"Create package manifest hash file: {filePath}");
|
||||
}
|
||||
|
||||
// 创建资源清单版本文件
|
||||
// 创建补丁清单版本文件
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageVersionFileName(buildParameters.PackageName);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
@@ -97,7 +97,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
ManifestContext manifestContext = new ManifestContext();
|
||||
byte[] bytesData = FileUtility.ReadAllBytes(packagePath);
|
||||
manifestContext.Manifest = ManifestTools.DeserializeFromBinary(bytesData, buildParameters.ManifestServices);
|
||||
manifestContext.Manifest = ManifestTools.DeserializeFromBinary(bytesData);
|
||||
context.SetContextObject(manifestContext);
|
||||
}
|
||||
}
|
||||
|
@@ -43,8 +43,7 @@ namespace YooAsset.Editor
|
||||
buildReport.Summary.EnableSharePackRule = buildParameters.EnableSharePackRule;
|
||||
buildReport.Summary.SingleReferencedPackAlone = buildParameters.SingleReferencedPackAlone;
|
||||
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
|
||||
buildReport.Summary.EncryptionServicesClassName = buildParameters.EncryptionServices == null ? "null" : buildParameters.EncryptionServices.GetType().FullName;
|
||||
buildReport.Summary.ManifestServicesClassName = buildParameters.ManifestServices == null ? "null" : buildParameters.ManifestServices.GetType().FullName;
|
||||
buildReport.Summary.EncryptionClassName = buildParameters.EncryptionServices == null ? "null" : buildParameters.EncryptionServices.GetType().FullName;
|
||||
if (buildParameters is BuiltinBuildParameters)
|
||||
{
|
||||
var builtinBuildParameters = buildParameters as BuiltinBuildParameters;
|
||||
|
@@ -1,15 +0,0 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class ManifestNone : IManifestServices
|
||||
{
|
||||
public byte[] ProcessManifest(byte[] fileData)
|
||||
{
|
||||
return fileData;
|
||||
}
|
||||
public byte[] RestoreManifest(byte[] fileData)
|
||||
{
|
||||
return fileData;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 446513b0ea9f5d445ade0cfb09c5073b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,13 +1,8 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public interface IBuildPipeline
|
||||
{
|
||||
/// <summary>
|
||||
/// 运行构建任务
|
||||
/// </summary>
|
||||
BuildResult Run(BuildParameters buildParameters, bool enableLog);
|
||||
}
|
||||
}
|
@@ -1,14 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class BuildPipelineAttribute : Attribute
|
||||
{
|
||||
public string PipelineName;
|
||||
|
||||
public BuildPipelineAttribute(string name)
|
||||
{
|
||||
this.PipelineName = name;
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user