diff --git a/Forest/Assets/PhxhSDK b/Forest/Assets/PhxhSDK new file mode 160000 index 0000000..c689899 --- /dev/null +++ b/Forest/Assets/PhxhSDK @@ -0,0 +1 @@ +Subproject commit c689899a54a45fe71f6a69d76961d47088f196e7 diff --git a/Forest/Assets/PhxhSDK/.gitignore b/Forest/Assets/PhxhSDK/.gitignore deleted file mode 100644 index 2997271..0000000 --- a/Forest/Assets/PhxhSDK/.gitignore +++ /dev/null @@ -1,75 +0,0 @@ -# This .gitignore file should be placed at the root of your Unity project directory -# -# Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore -# -/[Ll]ibrary/ -/[Tt]emp/ -/[Oo]bj/ -/[Bb]uild/ -/[Bb]uilds/ -/[Ll]ogs/ -/[Uu]ser[Ss]ettings/ - -# MemoryCaptures can get excessive in size. -# They also could contain extremely sensitive data -/[Mm]emoryCaptures/ - -# Recordings can get excessive in size -/[Rr]ecordings/ - -# Uncomment this line if you wish to ignore the asset store tools plugin -# /[Aa]ssets/AssetStoreTools* - -# Autogenerated Jetbrains Rider plugin -/[Aa]ssets/Plugins/Editor/JetBrains* - -# Visual Studio cache directory -.vs/ - -# Gradle cache directory -.gradle/ - -# Autogenerated VS/MD/Consulo solution and project files -ExportedObj/ -.consulo/ -*.csproj -*.unityproj -*.sln -*.suo -*.tmp -*.user -*.userprefs -*.pidb -*.booproj -*.svd -*.pdb -*.mdb -*.opendb -*.VC.db - -# Unity3D generated meta files -*.pidb.meta -*.pdb.meta -*.mdb.meta - -# Unity3D generated file on crash reports -sysinfo.txt - -# Builds -*.apk -*.aab -*.unitypackage -*.app - -# Crashlytics generated file -crashlytics-build.properties - -# Packed Addressables -/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin* - -# Temporary auto-generated Android Assets -/[Aa]ssets/[Ss]treamingAssets/aa.meta -/[Aa]ssets/[Ss]treamingAssets/aa/* - -# Mac -*.DS_Store diff --git a/Forest/Assets/PhxhSDK/AOT.meta b/Forest/Assets/PhxhSDK/AOT.meta deleted file mode 100644 index 6da008b..0000000 --- a/Forest/Assets/PhxhSDK/AOT.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: d56946792ef24427975f9f6ebdd85aa1 -timeCreated: 1708490322 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/AOT/ForceAOT.asmdef b/Forest/Assets/PhxhSDK/AOT/ForceAOT.asmdef deleted file mode 100644 index b84b025..0000000 --- a/Forest/Assets/PhxhSDK/AOT/ForceAOT.asmdef +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "ForceAOT", - "rootNamespace": "", - "references": [ - "GUID:e34a5702dd353724aa315fb8011f08c3", - "GUID:f51ebe6a0ceec4240a699833d6309b23", - "GUID:9e24947de15b9834991c9d8411ea37cf", - "GUID:593a5b492d29ac6448b1ebf7f035ef33", - "GUID:84651a3751eca9349aac36a66bba901b", - "GUID:13ba8ce62aa80c74598530029cb2d649" - ], - "includePlatforms": [], - "excludePlatforms": [], - "allowUnsafeCode": true, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": true, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false -} \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/AOT/ForceAOT.asmdef.meta b/Forest/Assets/PhxhSDK/AOT/ForceAOT.asmdef.meta deleted file mode 100644 index 721675f..0000000 --- a/Forest/Assets/PhxhSDK/AOT/ForceAOT.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: a57549a73a7740d48803470f3282422f -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/AOT/HybridCLR.meta b/Forest/Assets/PhxhSDK/AOT/HybridCLR.meta deleted file mode 100644 index 32b6cc8..0000000 --- a/Forest/Assets/PhxhSDK/AOT/HybridCLR.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 6f5bc95ef7bf4aa2ae49466a309d9637 -timeCreated: 1708574088 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/AOT/HybridCLR/HybridCLRHelper.cs b/Forest/Assets/PhxhSDK/AOT/HybridCLR/HybridCLRHelper.cs deleted file mode 100644 index 30a2f35..0000000 --- a/Forest/Assets/PhxhSDK/AOT/HybridCLR/HybridCLRHelper.cs +++ /dev/null @@ -1,247 +0,0 @@ -#if USE_HCLR -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using Cysharp.Threading.Tasks; -using HybridCLR; -using PhxhSDK.AOT.SimpleLoader; -using UnityEngine; - -namespace PhxhSDK.AOT -{ - public class HybridCLRHelper - { - const string META_DATA_DLL_PATH = "Assets/HotUpdateDlls/MetaDataDll/"; - const string HOT_UPDATE_DLL_PATH = "Assets/HotUpdateDlls/HotUpdateDll/"; - const string PHXH_DLL_NAME = "Phxh.dll"; - const string FRAMEWORK_DLL_NAME = "FrameWork.dll"; - const string GAMEPLAY_DLL_NAME = "GamePlay.dll"; - - private byte[] _dllBytes; - - private Dictionary _allHotUpdateAssemblies = new(); - - private readonly List _phxhDependencyDlls = new List() - { - }; - - private readonly List _frameWorkDependencyDlls = new List() - { - //不要随意改顺序! - }; - - private readonly List _gamePlayDependencyDlls = new List() - { - //不要随意改顺序! - "BehaviorDesigner.Runtime.dll", - //"BestHTTP.dll", - "DOTweenCSharp.dll", - }; - - //所有使用了RuntimeInitializeOnLoadMethod attribute的程序集 - private readonly List _hasRuntimeInitializeOnLoadMethodAssemblies = new List() - { - "BehaviorDesigner.Runtime", - //"BestHTTP", - "GamePlay", - }; - - private List _aotAssemblyList = new List(); - - private ISimpleLoader _loader; - - public async UniTask LoadAssemblies() - { - await LoadPhxhDependencyAssemblies(); - await LoadPhxhAssembies(); - await LoadFrameworkDependencyAssemblies(); - await LoadFrameWorkAssemblies(); - await LoadMetadataForAOTAssemblies(); - await LoadGamePlayDependencyAssemblies(); - await LoadGamePlayAssemblies(); - await ReloadAddressableCatalog(); - _ExecuteRuntimeInitializeOnLoadMethodAttribute(); - await UniTask.NextFrame(); - } - - /// - /// Addressable初始化时热更新代码所对应的ScriptableObject的类型会被识别为System.Object,需要在热更新dll加载完后重新加载一下Addressable的Catalog - /// https://hybridclr.doc.code-philosophy.com/docs/help/commonerrors - /// - /// - private async UniTask ReloadAddressableCatalog() - { - #if !USE_YOO - await SimpleLoader_Addressables.ReloadAddressableCatalog(); - #endif - await UniTask.NextFrame(); - } - - private void _TryHandleMethod(MethodInfo method, List runtimeMethods) - { - if (!method.IsStatic) - return; - var runtimeInitializedAttribute = typeof(RuntimeInitializeOnLoadMethodAttribute); - var attri = method.GetCustomAttribute(runtimeInitializedAttribute); - if (attri == null) - return; - var sequence = (int)((RuntimeInitializeOnLoadMethodAttribute)attri).loadType; - var methodInfo = new MethodExecutionInfo(method, sequence); - runtimeMethods.Add(methodInfo); - } - - private void _ExecuteRuntimeInitializeOnLoadMethodAttribute() - { - List runtimeMethods = new(); - foreach (var assemblyName in _hasRuntimeInitializeOnLoadMethodAssemblies) - { - var assembly = GetAssembly(assemblyName); - if (assembly == null) - { - Debug.LogError($"找不到使用过RuntimeInitializeOnLoadMethod的assembly,name:{assemblyName}"); - continue; - } - - foreach (var type in assembly.GetTypes()) - { - var methods = type.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); - foreach (var method in methods) - { - _TryHandleMethod(method, runtimeMethods); - } - } - } - - runtimeMethods.Sort((a, b) => b.sequnence.CompareTo(a.sequnence)); - foreach (var methodInfo in runtimeMethods) - { - Debug.Log($"call method methodName:{methodInfo.method.Name} sequnence:{methodInfo.sequnence}"); - methodInfo.method.Invoke(null, null); - } - - Debug.Log("调用RuntimeInitializeOnLoadMethod结束!"); - } - - private Assembly GetAssembly(string assemblyName) - { - assemblyName = assemblyName.Replace(".dll", ""); - IEnumerable allAssemblies = _allHotUpdateAssemblies.Values; - return allAssemblies.First(assembly => assembly.FullName.Contains(assemblyName)); - } - - private async UniTask LoadSingleHotUpdateAssembly(string dllName) - { - var path = $"{HOT_UPDATE_DLL_PATH}{dllName}.bytes"; - await ReadDllBytes(path); - if (_dllBytes != null) - { - var assembly = Assembly.Load(_dllBytes); - _allHotUpdateAssemblies.Add(assembly.FullName, assembly); - Debug.Log($"Load Assembly success,assembly Name:{assembly.FullName}"); - // foreach (var type in GetAssembly(dllName).GetTypes()) - // { - // Debug.Log($"type:{type} in assembly:{GAMEPLAY_DLL_NAME}"); - // } - } - await UniTask.NextFrame(); - } - - //加载GamePlay程序集 - private async UniTask LoadGamePlayAssemblies() - { - await LoadSingleHotUpdateAssembly(GAMEPLAY_DLL_NAME); - Debug.Log("加载GamePlay程序集结束!"); - } - - //加载GamePlay依赖的第三方程序集 - private async UniTask LoadGamePlayDependencyAssemblies() - { - foreach (var dllName in _gamePlayDependencyDlls) - { - await LoadSingleHotUpdateAssembly(dllName); - } - - Debug.Log("加载GamePlay依赖程序集结束!"); - } - - //加载Framework程序集 - private async UniTask LoadFrameWorkAssemblies() - { - await LoadSingleHotUpdateAssembly(FRAMEWORK_DLL_NAME); - Debug.Log("加载Framework程序集结束!"); - } - - //加载FrameWork依赖的第三方热更序集 - private async UniTask LoadFrameworkDependencyAssemblies() - { - foreach (var dllName in _frameWorkDependencyDlls) - { - await LoadSingleHotUpdateAssembly(dllName); - } - - Debug.Log("加载Framework依赖程序集结束!"); - } - - private async UniTask LoadPhxhAssembies() - { - await LoadSingleHotUpdateAssembly(PHXH_DLL_NAME); - Debug.Log("加载Phxh程序集结束!"); - } - - private async UniTask LoadPhxhDependencyAssemblies() - { - foreach (var dllName in _phxhDependencyDlls) - { - await LoadSingleHotUpdateAssembly(dllName); - } - - Debug.Log("加载Phxh依赖程序集结束!"); - } - - //补充元数据 - private async UniTask LoadMetadataForAOTAssemblies() - { - var aotAssemblies = _aotAssemblyList; - if (aotAssemblies == null) - { - Debug.LogError($"LoadMetadataForAOTAssemblies failed, PatchedAOTAssemblyList is null!"); - return; - } - - foreach (var aotDllName in aotAssemblies) - { - var path = $"{META_DATA_DLL_PATH}{aotDllName}.bytes"; - await ReadDllBytes(path); - if (_dllBytes != null) - { - var err = RuntimeApi.LoadMetadataForAOTAssembly(_dllBytes, HomologousImageMode.SuperSet); - Debug.Log($"LoadMetadataForAOTAssembly:{aotDllName}. ret:{err}"); - } - } - - Debug.Log("补充元数据结束!"); - } - - private async UniTask ReadDllBytes(string path) - { - _dllBytes = await _loader.LoadDllBytes(path); - if (_dllBytes == null) - { - Debug.LogError($"cant load dll,path:{path}"); - return; - } - await _loader.UnloadDll(path); - } - - public void RegistLoader(ISimpleLoader loader) - { - _loader = loader; - } - - public void SetDllList(IReadOnlyList dllList) - { - _aotAssemblyList.AddRange(dllList); - } - } -} -#endif \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/AOT/HybridCLR/HybridCLRHelper.cs.meta b/Forest/Assets/PhxhSDK/AOT/HybridCLR/HybridCLRHelper.cs.meta deleted file mode 100644 index aa3c67a..0000000 --- a/Forest/Assets/PhxhSDK/AOT/HybridCLR/HybridCLRHelper.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 88d9df6663654361adc0bec9396b21c9 -timeCreated: 1708574103 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/AOT/HybridCLR/MethodExecutionInfo.cs b/Forest/Assets/PhxhSDK/AOT/HybridCLR/MethodExecutionInfo.cs deleted file mode 100644 index 31b89ea..0000000 --- a/Forest/Assets/PhxhSDK/AOT/HybridCLR/MethodExecutionInfo.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Reflection; -namespace PhxhSDK.AOT -{ - public class MethodExecutionInfo - { - public MethodInfo method; - public int sequnence; - - public MethodExecutionInfo(MethodInfo method, int sequnence) - { - this.method = method; - this.sequnence = sequnence; - } - } -} diff --git a/Forest/Assets/PhxhSDK/AOT/HybridCLR/MethodExecutionInfo.cs.meta b/Forest/Assets/PhxhSDK/AOT/HybridCLR/MethodExecutionInfo.cs.meta deleted file mode 100644 index d8de542..0000000 --- a/Forest/Assets/PhxhSDK/AOT/HybridCLR/MethodExecutionInfo.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: d048804b8b42464d95190aa5ba3546a2 -timeCreated: 1708576339 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/AOT/SimpleLoader.meta b/Forest/Assets/PhxhSDK/AOT/SimpleLoader.meta deleted file mode 100644 index 2fc2646..0000000 --- a/Forest/Assets/PhxhSDK/AOT/SimpleLoader.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 4d06325ab1cf455f88fb987aa35ddb2b -timeCreated: 1708574646 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/AOT/SimpleLoader/ISimpleLoader.cs b/Forest/Assets/PhxhSDK/AOT/SimpleLoader/ISimpleLoader.cs deleted file mode 100644 index ceb8185..0000000 --- a/Forest/Assets/PhxhSDK/AOT/SimpleLoader/ISimpleLoader.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Cysharp.Threading.Tasks; -namespace PhxhSDK.AOT.SimpleLoader -{ - public interface ISimpleLoader - { - UniTask LoadDllBytes(string path); - UniTask UnloadDll(string path); - - UniTask LoadSceneAsync(string path); - } -} diff --git a/Forest/Assets/PhxhSDK/AOT/SimpleLoader/ISimpleLoader.cs.meta b/Forest/Assets/PhxhSDK/AOT/SimpleLoader/ISimpleLoader.cs.meta deleted file mode 100644 index c18a9bc..0000000 --- a/Forest/Assets/PhxhSDK/AOT/SimpleLoader/ISimpleLoader.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 202a545f2ec148c19eb199a62d92e0b8 -timeCreated: 1708574653 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/AOT/SimpleLoader/SimpleLoader_Addressables.cs b/Forest/Assets/PhxhSDK/AOT/SimpleLoader/SimpleLoader_Addressables.cs deleted file mode 100644 index 7066cca..0000000 --- a/Forest/Assets/PhxhSDK/AOT/SimpleLoader/SimpleLoader_Addressables.cs +++ /dev/null @@ -1,52 +0,0 @@ -#if USE_ADDRESSABLES -using System.Collections.Generic; -using Cysharp.Threading.Tasks; -using UnityEngine.AddressableAssets; -using UnityEngine.ResourceManagement.AsyncOperations; -using UnityEngine; - -namespace PhxhSDK.AOT.SimpleLoader -{ - public class SimpleLoader_Addressables : ISimpleLoader - { - - private Dictionary _loadedAssets = new Dictionary(); - - public async UniTask LoadDllBytes(string path) - { - var op = Addressables.LoadAssetAsync(path); - await op; - if (op.Status == AsyncOperationStatus.Succeeded) - { - _loadedAssets.Add(path, op.Result); - return op.Result.bytes; - } - return null; - } - public UniTask UnloadDll(string path) - { - if (_loadedAssets.TryGetValue(path, out var asset)) - { - Addressables.Release(asset); - _loadedAssets.Remove(path); - } - return UniTask.CompletedTask; - } - public async UniTask LoadSceneAsync(string path) - { - await Addressables.LoadSceneAsync(path); - } - - public static async UniTask ReloadAddressableCatalog() - { - var op = Addressables.LoadContentCatalogAsync($"{Addressables.RuntimePath}/catalog.json"); - await op; - if (op.Status != AsyncOperationStatus.Succeeded) - { - Debug.LogError( - $"load content catalog failed, exception:{op.OperationException.Message} \r\n {op.OperationException.StackTrace}"); - } - } - } -} -#endif \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/AOT/SimpleLoader/SimpleLoader_Addressables.cs.meta b/Forest/Assets/PhxhSDK/AOT/SimpleLoader/SimpleLoader_Addressables.cs.meta deleted file mode 100644 index eda07b6..0000000 --- a/Forest/Assets/PhxhSDK/AOT/SimpleLoader/SimpleLoader_Addressables.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 33021c41fc0a4368a91312930aa72d0b -timeCreated: 1708574988 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/AOT/SimpleLoader/SimpleLoader_YooAsset.cs b/Forest/Assets/PhxhSDK/AOT/SimpleLoader/SimpleLoader_YooAsset.cs deleted file mode 100644 index 955bc20..0000000 --- a/Forest/Assets/PhxhSDK/AOT/SimpleLoader/SimpleLoader_YooAsset.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Collections.Generic; -using Cysharp.Threading.Tasks; -using UnityEngine; -using YooAsset; - -namespace PhxhSDK.AOT.SimpleLoader -{ - public class SimpleLoader_YooAsset : ISimpleLoader - { - - private Dictionary _loadedAssets = new Dictionary(); - - public async UniTask LoadDllBytes(string path) - { - var op = YooAssets.LoadAssetAsync(path); - await op; - _loadedAssets.Add(path, op); - if (op.Status == EOperationStatus.Succeed) - { - return (op.AssetObject as TextAsset)?.bytes; - } - return null; - } - - public UniTask UnloadDll(string path) - { - if (_loadedAssets.TryGetValue(path, out var asset)) - { - asset.Release(); - _loadedAssets.Remove(path); - } - return UniTask.CompletedTask; - } - - public async UniTask LoadSceneAsync(string path) - { - await YooAssets.LoadSceneAsync(path); - } - } -} diff --git a/Forest/Assets/PhxhSDK/AOT/SimpleLoader/SimpleLoader_YooAsset.cs.meta b/Forest/Assets/PhxhSDK/AOT/SimpleLoader/SimpleLoader_YooAsset.cs.meta deleted file mode 100644 index 47f5ddf..0000000 --- a/Forest/Assets/PhxhSDK/AOT/SimpleLoader/SimpleLoader_YooAsset.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 91a500ba67764ceaa13e4305e58ed1d5 -timeCreated: 1708576470 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/AOT/VersionUpdate.meta b/Forest/Assets/PhxhSDK/AOT/VersionUpdate.meta deleted file mode 100644 index 9a8cc72..0000000 --- a/Forest/Assets/PhxhSDK/AOT/VersionUpdate.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 04d521a802e944d88b4e057cdb0fdf8f -timeCreated: 1708580107 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/Data.meta b/Forest/Assets/PhxhSDK/AOT/VersionUpdate/Data.meta deleted file mode 100644 index 06f350f..0000000 --- a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/Data.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 273bf894badf42508bcf6b111faa5e5d -timeCreated: 1708921974 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/Data/PackDataInst.cs b/Forest/Assets/PhxhSDK/AOT/VersionUpdate/Data/PackDataInst.cs deleted file mode 100644 index d340524..0000000 --- a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/Data/PackDataInst.cs +++ /dev/null @@ -1,159 +0,0 @@ -using System; -using UnityEngine; - -namespace PhxhSDK.AOT.VersionUpdate -{ - public class PackDataInst - { - public static PackDataInst inst { get; private set; } - - /// - /// 更新本地信息 - /// 初始存放于resources文件夹下 - /// 读取后存放与playerprefs中 - /// - public UpdateLocalInfo localInfo { get; private set; } - - private static string _localInfoKey = "LocalInfo_"; - private const string PathInResources = "LocalInfo"; - - public static void CreateInst() - { - if (inst != null) return; - var textAsset = Resources.Load(PathInResources); - if (textAsset == null) - { - throw new Exception("本地信息文件不存在:" + PathInResources); - } - var textJson = textAsset.text; - var infoInResources = JsonUtility.FromJson(textJson); - Resources.UnloadAsset(textAsset); - - var versionInResources = infoInResources.version; - Debug.Log("Resources中的版本信息:" + versionInResources); - - inst = new PackDataInst(); - _localInfoKey += Application.productName; - Debug.Log("LocalInfoKey:" + _localInfoKey); - var json = PlayerPrefs.GetString(_localInfoKey); - if (string.IsNullOrEmpty(json)) - { - Debug.Log("PlayerPrefs中无本地信息,使用Resources中的信息:" + textJson); - inst.localInfo = infoInResources; - inst.SaveData(); - } - else - { - Debug.Log("读取PlayerPrefs本地信息:" + json); - inst.localInfo = JsonUtility.FromJson(json); - } - // version使用resources中的 - inst.localInfo.version = versionInResources; - } - - public void SaveData() - { - var json = JsonUtility.ToJson(localInfo); - PlayerPrefs.SetString(_localInfoKey, json); - PlayerPrefs.Save(); - } - - public static string GetRuntimePlatform() - { - switch (Application.platform) - { - case RuntimePlatform.WindowsPlayer: - case RuntimePlatform.WindowsEditor: - #if AB_DEBUG - return "Android"; - #else - return "Windows"; - #endif - case RuntimePlatform.Android: - return "Android"; - case RuntimePlatform.IPhonePlayer: - return "iOS"; - default: - return "Unknown"; - } - } - - #if UNITY_EDITOR - [UnityEditor.MenuItem("Test/YooAsset/创建本地信息文件")] - public static void TestFunc() - { - var key = "LocalInfo_" + Application.productName; - PlayerPrefs.DeleteKey(key); - PlayerPrefs.Save(); - - var info = new UpdateLocalInfo(); - info.version = "0.1.0"; - info.workSpace = "Dev"; - info.buildCount = 1; - CreateResourceJson(info); - - // 弹出提示框 - UnityEditor.EditorUtility.DisplayDialog("创建本地信息", "创建成功", "确定"); - } - - [UnityEditor.MenuItem("Test/YooAsset/清除本地信息文件")] - public static void ClearPlayerData() - { - var key = "LocalInfo_" + Application.productName; - PlayerPrefs.DeleteKey(key); - PlayerPrefs.Save(); - // 弹出提示框 - UnityEditor.EditorUtility.DisplayDialog("清除本地信息", "清除成功", "确定"); - } - #endif - - public static void CreateResourceJson(UpdateLocalInfo info) - { - #if UNITY_EDITOR - var savePath = Application.dataPath + "/Resources/" + PathInResources + ".json"; - var json = JsonUtility.ToJson(info); - var dirPath = Application.dataPath + "/Resources"; - if (!System.IO.Directory.Exists(dirPath)) - { - System.IO.Directory.CreateDirectory(dirPath); - } - System.IO.File.WriteAllText(savePath, json); - UnityEditor.AssetDatabase.Refresh(); - #else - Debug.LogError("该方法仅能在Editor模式下使用"); - #endif - } - - public static void CreateBuildCount(string workSpacke, - string version, - int count) - { - var combinePath = Application.dataPath + $"/../Yoo_Build_Cache/{workSpacke}/{version}"; - if (!System.IO.Directory.Exists(combinePath)) - { - System.IO.Directory.CreateDirectory(combinePath); - } - var savePath = combinePath + "/build_count.txt"; - System.IO.File.WriteAllText(savePath, count.ToString()); - Debug.Log("创建build_count.txt成功 version:" + version + " count:" + count); - } - - public static int ReadBuildCount(string workSpace, string version) - { - #if UNITY_EDITOR - var combinePath = Application.dataPath + $"/../Yoo_Build_Cache/{workSpace}/{version}/build_count.txt"; - if (!System.IO.File.Exists(combinePath)) - { - Debug.LogError("build_count.txt不存在,打更新包时请确保build_count.txt存在"); - throw new System.Exception("build_count.txt不存在"); - } - var count = System.IO.File.ReadAllText(combinePath); - Debug.Log("读取build_count.txt成功 version:" + version + " count:" + count); - return int.Parse(count); - #else - Debug.LogError("该方法仅能在Editor模式下使用"); - return 1; - #endif - } - } -} diff --git a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/Data/PackDataInst.cs.meta b/Forest/Assets/PhxhSDK/AOT/VersionUpdate/Data/PackDataInst.cs.meta deleted file mode 100644 index 9873d38..0000000 --- a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/Data/PackDataInst.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 44eb7b74a8c94e1cb705377229681d81 -timeCreated: 1708922010 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/Data/UpdateLocalInfo.cs b/Forest/Assets/PhxhSDK/AOT/VersionUpdate/Data/UpdateLocalInfo.cs deleted file mode 100644 index 4344c90..0000000 --- a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/Data/UpdateLocalInfo.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -namespace PhxhSDK.AOT.VersionUpdate -{ - [Serializable] - public class UpdateLocalInfo - { - public string workSpace = "DevYoo"; - public string version = "0.2.0"; - public string serverUrl = "http://132.232.113.98"; - public int buildCount = 1; - public string pathRoot = "Build"; - public string localFullVersion = "empty"; - } -} diff --git a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/Data/UpdateLocalInfo.cs.meta b/Forest/Assets/PhxhSDK/AOT/VersionUpdate/Data/UpdateLocalInfo.cs.meta deleted file mode 100644 index 3568c1a..0000000 --- a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/Data/UpdateLocalInfo.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 4eeb9040a2844743bec5c9b35105f806 -timeCreated: 1708921897 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/EVersionUpdateType.cs b/Forest/Assets/PhxhSDK/AOT/VersionUpdate/EVersionUpdateType.cs deleted file mode 100644 index 8143160..0000000 --- a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/EVersionUpdateType.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace PhxhSDK.AOT.VersionUpdate -{ - public enum EVersionUpdateType - { - - /// - /// 不需要更新 - /// - NoUpdate, - - /// - /// 资源更新 - /// - ResUpdate, - - /// - /// 整包更新 - /// - PackUpdate, - - /// - /// 出错 - /// - Error, - - } -} diff --git a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/EVersionUpdateType.cs.meta b/Forest/Assets/PhxhSDK/AOT/VersionUpdate/EVersionUpdateType.cs.meta deleted file mode 100644 index a2cd072..0000000 --- a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/EVersionUpdateType.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 1b70d270da4c44dbaefd50e9835c573b -timeCreated: 1708580602 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/IVersionUpdate.cs b/Forest/Assets/PhxhSDK/AOT/VersionUpdate/IVersionUpdate.cs deleted file mode 100644 index 742b897..0000000 --- a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/IVersionUpdate.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Cysharp.Threading.Tasks; -namespace PhxhSDK.AOT.VersionUpdate -{ - public interface IVersionUpdate - { - - UniTask CheckVersion(); - - UniTask UpdateRes(); - - VersionUpdateInfo GetVersionInfo(); - - } -} diff --git a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/IVersionUpdate.cs.meta b/Forest/Assets/PhxhSDK/AOT/VersionUpdate/IVersionUpdate.cs.meta deleted file mode 100644 index e6e3e22..0000000 --- a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/IVersionUpdate.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: dc873595eb49408794db5ba8c13a4878 -timeCreated: 1708580756 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/IVersionUpdateUI.cs b/Forest/Assets/PhxhSDK/AOT/VersionUpdate/IVersionUpdateUI.cs deleted file mode 100644 index 9c4a16e..0000000 --- a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/IVersionUpdateUI.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Cysharp.Threading.Tasks; -namespace PhxhSDK.AOT.VersionUpdate -{ - public interface IVersionUpdateUI - { - UniTask ShowDialog(string title, - string content); - - void UpdateProgress(float progress); - void UpdateProgressText(string text); - - void CloseAll(); - } -} diff --git a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/IVersionUpdateUI.cs.meta b/Forest/Assets/PhxhSDK/AOT/VersionUpdate/IVersionUpdateUI.cs.meta deleted file mode 100644 index 1ff028f..0000000 --- a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/IVersionUpdateUI.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 0d8b5e01044d4ecdb7f5ef7cf7435045 -timeCreated: 1708580151 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/VersionUpdateHandle.cs b/Forest/Assets/PhxhSDK/AOT/VersionUpdate/VersionUpdateHandle.cs deleted file mode 100644 index 317e177..0000000 --- a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/VersionUpdateHandle.cs +++ /dev/null @@ -1,66 +0,0 @@ -using Cysharp.Threading.Tasks; -using UnityEngine; -namespace PhxhSDK.AOT.VersionUpdate -{ - public class VersionUpdateHandle - { - - private readonly IVersionUpdate _updateImpl; - private readonly IVersionUpdateUI _updateUI; - - public VersionUpdateHandle(IVersionUpdateUI ui) - { - #if USE_YOO - _updateImpl = new VersionUpdate_YooAsset(ui); - #else - _updateImpl = new VersionUpdate_Addressables(ui); - #endif - - _updateUI = ui; - } - - public async UniTask CheckUpdate() - { - Debug.Log("开始检查版本更新"); - var checkResult = await _CheckVersion(); - switch (checkResult) - { - case EVersionUpdateType.NoUpdate: - Debug.Log("无需更新"); - return true; - case EVersionUpdateType.ResUpdate: - Debug.Log("资源更新"); - await _UpdateRes(); - return true; - default: - _updateUI.UpdateProgressText("Start Failed!"); - Debug.LogError("暂未实现的更新类型: " + checkResult); - return false; - } - } - - private async UniTask _CheckVersion() - { - return await _updateImpl.CheckVersion(); - } - - private async UniTask _UpdateRes() - { - var versionInfo = _updateImpl.GetVersionInfo(); - var totalBytes = versionInfo.totalBytes; - var totalMb = totalBytes / 1024f / 1024f; - var totalMbStr = totalMb.ToString("F2"); - var showStr = $"Find New Version: {versionInfo.newVersion}\n" + - $"Current Version: {versionInfo.oldVersion}\n" + - $"Need Download Size: {totalMbStr}MB\n" + - $"Continue?"; - var result = await _updateUI.ShowDialog("Need Update", showStr); - if (!result) - { - return false; - } - return await _updateImpl.UpdateRes(); - } - - } -} diff --git a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/VersionUpdateHandle.cs.meta b/Forest/Assets/PhxhSDK/AOT/VersionUpdate/VersionUpdateHandle.cs.meta deleted file mode 100644 index 1232a3d..0000000 --- a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/VersionUpdateHandle.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 3aaed81d361946f8ae7a260f2b3445b1 -timeCreated: 1708580492 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/VersionUpdateInfo.cs b/Forest/Assets/PhxhSDK/AOT/VersionUpdate/VersionUpdateInfo.cs deleted file mode 100644 index 71f914b..0000000 --- a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/VersionUpdateInfo.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace PhxhSDK.AOT.VersionUpdate -{ - public class VersionUpdateInfo - { - public string oldVersion = "unknown"; - public string newVersion = "unknown"; - public long totalBytes = 0; - } -} diff --git a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/VersionUpdateInfo.cs.meta b/Forest/Assets/PhxhSDK/AOT/VersionUpdate/VersionUpdateInfo.cs.meta deleted file mode 100644 index 1ffaf01..0000000 --- a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/VersionUpdateInfo.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 32d04333b6a24d26a5707f5e4e619892 -timeCreated: 1708581325 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/VersionUpdate_Addressables.cs b/Forest/Assets/PhxhSDK/AOT/VersionUpdate/VersionUpdate_Addressables.cs deleted file mode 100644 index fff4b0e..0000000 --- a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/VersionUpdate_Addressables.cs +++ /dev/null @@ -1,191 +0,0 @@ -#if USE_ADDRESSABLES -using System; -using System.Collections; -using System.Collections.Generic; -using Cysharp.Threading.Tasks; -using PhxhSDK.AOT.SimpleLoader; -using UnityEngine; -using UnityEngine.AddressableAssets; -using UnityEngine.ResourceManagement.AsyncOperations; -namespace PhxhSDK.AOT.VersionUpdate -{ - public class VersionUpdate_Addressables : IVersionUpdate - { - - private IVersionUpdateUI _versionUpdateUI; - - private VersionUpdateInfo _versionUpdateInfo = new VersionUpdateInfo(); - - [Serializable] - private class DownloadContent - { - public List catalogs = new(); - } - - //记录在playerPres里的需要下载的catalogs的ID - const string DOWNLOAD_CATALOGS_ID = "DownloadCatalogs"; - - //version update - private AsyncOperationHandle _downloadOP; - - //此对象里保存了需要下载的catalog,每次获取新的catalog会将此对象保存到手机上,如果在下载的过程中关闭了游戏,下次打开还能拿到catalog继续下载 - private DownloadContent _downloadContent = new(); - - private List _KeysNeedToDownload = new(); - - private bool HasContentToDownload => _downloadContent != null && _downloadContent.catalogs != null && - _downloadContent.catalogs.Count > 0; - - public VersionUpdate_Addressables(IVersionUpdateUI ui) - { - _versionUpdateUI = ui; - } - - public async UniTask CheckVersion() - { - EVersionUpdateType result = EVersionUpdateType.Error; - //todo 如果包体版本不一致则提示用户去app store重新下载 - var checkUpdateOP = Addressables.CheckForCatalogUpdates(false); - await checkUpdateOP; - if (checkUpdateOP.Status == AsyncOperationStatus.Succeeded) - { - result = EVersionUpdateType.NoUpdate; - _downloadContent.catalogs = checkUpdateOP.Result; - if (HasContentToDownload) - { - Debug.Log("new version on server"); - //如果服务器上的catalog和本地不一致,则覆盖上一次需要下载的被内容 - var jsonStr = JsonUtility.ToJson(_downloadContent); - PlayerPrefs.SetString(DOWNLOAD_CATALOGS_ID, jsonStr); - PlayerPrefs.Save(); - } - else - { - if (PlayerPrefs.HasKey(DOWNLOAD_CATALOGS_ID)) - { - Debug.Log("there are some contents remains from last downloading"); - var jsonStr = PlayerPrefs.GetString(DOWNLOAD_CATALOGS_ID); - JsonUtility.FromJsonOverwrite(jsonStr, _downloadContent); - } - } - - if (HasContentToDownload) - { - var updateCatalogOP = Addressables.UpdateCatalogs(_downloadContent.catalogs, false); - await updateCatalogOP; - if (updateCatalogOP.Status == AsyncOperationStatus.Succeeded) - { - _KeysNeedToDownload.Clear(); - foreach (var resourceLocator in updateCatalogOP.Result) - { - _KeysNeedToDownload.AddRange(resourceLocator.Keys); - } - - if (HasContentToDownload) - { - var downloadSizeOp = Addressables.GetDownloadSizeAsync((IEnumerable)_KeysNeedToDownload); - await downloadSizeOp; - Debug.Log($"download size: {downloadSizeOp.Result / (1024f * 1024f)}MB"); - result = EVersionUpdateType.ResUpdate; - _versionUpdateInfo.totalBytes = downloadSizeOp.Result; - - Addressables.Release(downloadSizeOp); - } - else - { - result = EVersionUpdateType.NoUpdate; - } - - } - else - { - Debug.LogError($"Update catalog failed!exception:{updateCatalogOP.OperationException.Message}"); - } - - Addressables.Release(updateCatalogOP); - } - } - else - { - Debug.LogError($"CheckUpdate failed!exception:{checkUpdateOP.OperationException.Message}"); - } - - Addressables.Release(checkUpdateOP); - await SimpleLoader_Addressables.ReloadAddressableCatalog(); - Debug.Log($"版本检查结束,是否有需要下载的内容:{HasContentToDownload}"); - - return result; - } - - //下载资源 - private async UniTask Download() - { - //_downloadStuckTime = 0; - // //下载经常在100%的时候卡住,参考:https://forum.unity.com/threads/addressables-1-14-2-downloaddependenciesasync-does-not-complete-randomly.966671/ - // //倒数第二个回答 - // var asyncLoadResources = Addressables.LoadResourceLocationsAsync((IEnumerable)_KeysNeedToDownload, - // Addressables.MergeMode.Union, null); - // IList dependencyLoadList = new List(); - // yield return asyncLoadResources; - // foreach (var item in asyncLoadResources.Result) - // { - // dependencyLoadList.Add(item); - // } - // - // Addressables.Release(asyncLoadResources); - // - // _downloadOP = - // Addressables.DownloadDependenciesAsync(dependencyLoadList); - - _downloadOP = - Addressables.DownloadDependenciesAsync((IEnumerable)_KeysNeedToDownload, Addressables.MergeMode.Union, false); - - // while (!_downloadOP.IsDone) - // { - // RefreshDownLoadStatus(); - // if (!CheckIfNeedReDownload()) - // yield return 0; - // else - // { - // //下载会经常卡在99%,此时还剩下很少的资源要下载,可以直接放弃下载,进入游戏 - // //经过尝试,上述方法行不通,_downloadOp不能被终止,如果直接release的话会导致后续逻辑报错 - // Debug.LogError($"下载卡住超过时间上限,放弃下载!"); - // yield return _downloadOP; - // } - // } - - _versionUpdateUI.UpdateProgressText("Start Downloading..."); - - while (_downloadOP.IsValid() && !_downloadOP.IsDone) - { - await UniTask.DelayFrame(1); - var downloadStatus = _downloadOP.GetDownloadStatus(); - _versionUpdateUI.UpdateProgress(downloadStatus.Percent); - } - - if (_downloadOP.Status == AsyncOperationStatus.Succeeded) - Debug.Log($"下载完毕!"); - else - Debug.LogError($"Download Update Content Failed! exception:{_downloadOP.OperationException.Message} \r\n {_downloadOP.OperationException.StackTrace}"); - - Addressables.Release(_downloadOP); - - //清除需要下载的内容 - Debug.Log($"delete key:{DOWNLOAD_CATALOGS_ID}"); - PlayerPrefs.DeleteKey(DOWNLOAD_CATALOGS_ID); - - return true; - } - - public async UniTask UpdateRes() - { - return await Download(); - } - public VersionUpdateInfo GetVersionInfo() - { - return _versionUpdateInfo; - } - - } -} -#endif \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/VersionUpdate_Addressables.cs.meta b/Forest/Assets/PhxhSDK/AOT/VersionUpdate/VersionUpdate_Addressables.cs.meta deleted file mode 100644 index f2437f1..0000000 --- a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/VersionUpdate_Addressables.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 74a3780a1779428a88fbde5745bdc8b8 -timeCreated: 1708580803 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/VersionUpdate_YooAsset.cs b/Forest/Assets/PhxhSDK/AOT/VersionUpdate/VersionUpdate_YooAsset.cs deleted file mode 100644 index 15fda26..0000000 --- a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/VersionUpdate_YooAsset.cs +++ /dev/null @@ -1,196 +0,0 @@ -using Cysharp.Threading.Tasks; -using UnityEngine; -using YooAsset; -namespace PhxhSDK.AOT.VersionUpdate -{ - public class VersionUpdate_YooAsset : IVersionUpdate - { - - private VersionUpdateInfo _versionInfo = new VersionUpdateInfo(); - private ResourceDownloaderOperation _downloaderOperation_Default; - private ResourceDownloaderOperation _downloaderOperation_Raw; - private IVersionUpdateUI _updateUI; - private long _totalNeedDownloadBytes; - private long _currentDownLoadBytesDefault; - private long _currentDownloadBytesRaw; - private string _serverVersion; - - public VersionUpdate_YooAsset(IVersionUpdateUI ui) - { - _updateUI = ui; - } - - public async UniTask _CreateDownloader(ResourcePackage package) - { - Debug.Log("[LTRes]开始获取package:" + package.PackageName); - - var operation = package.UpdatePackageVersionAsync(); - await operation.Task; - - if (operation.Status == EOperationStatus.Succeed) - { - var packageCRC = operation.PackageVersion; - Debug.Log($"[LTRes]获取到服务器CRC:{packageCRC}"); - var op = package.UpdatePackageManifestAsync(packageCRC, true); - await op.Task; - - Debug.Log("[LTRes]开始更新补丁清单"); - if (op.Status == EOperationStatus.Succeed) - { - Debug.Log("[LTRes]更新补丁清单成功"); - var downloadingMaxNum = 10; - var failedTryAgain = 3; - var downloader = package.CreateResourceDownloader(downloadingMaxNum, failedTryAgain); - return downloader; - } - } - return null; - } - - public async UniTask CheckVersion() - { - // TODO: 这里可以做自定义版本检查 - var package = YooAssetHelper.defaultPackage; - - UpdatePackageVersionOperation operation = package.UpdatePackageVersionAsync(); - await operation.Task; - - // var localCRC = "unknown"; - // try - // { - // localCRC = package.GetPackageVersion(); - // } - // catch (System.Exception e) - // { - // Debug.LogError($"[LTRes]获取本地CRC失败:{e}"); - // return EVersionUpdateType.Error; - // } - // Debug.Log($"[LTRes]获取到本地crc:{localCRC}"); - - if (operation.Status == EOperationStatus.Succeed) - { - var packageCRC = operation.PackageVersion; - Debug.Log($"[LTRes]获取到服务器CRC:{packageCRC}"); - _serverVersion = packageCRC; - // 更新补丁清单 - UpdatePackageManifestOperation op = package.UpdatePackageManifestAsync(packageCRC, true); - await op.Task; - - Debug.Log("[LTRes]开始更新补丁清单"); - if (op.Status == EOperationStatus.Succeed) - { - Debug.Log("[LTRes]更新补丁清单成功"); - var downloadingMaxNum = 10; - var failedTryAgain = 3; - var downloader = package.CreateResourceDownloader(downloadingMaxNum, failedTryAgain); - _downloaderOperation_Default = downloader; - - // 添加原生文件下载 - var rawDownloader = await _CreateDownloader(YooAssetHelper.rawPackage); - _downloaderOperation_Raw = rawDownloader; - - var localCRC = PackDataInst.inst.localInfo.localFullVersion; - var totalDownloadCount = _downloaderOperation_Default.TotalDownloadCount + _downloaderOperation_Raw.TotalDownloadCount; - if (totalDownloadCount == 0) - { - Debug.Log($"[LTRes]没有需要下载的文件,无需更新,本地CRC:{localCRC} 服务器CRC:{packageCRC}"); - _SaveVersionToLocal(); - return EVersionUpdateType.NoUpdate; - } - - var totalDownloadBytes = _downloaderOperation_Default.TotalDownloadBytes + _downloaderOperation_Raw.TotalDownloadBytes; - - _versionInfo.newVersion = packageCRC; - _versionInfo.oldVersion = localCRC; - _versionInfo.totalBytes = totalDownloadBytes; - _totalNeedDownloadBytes = totalDownloadBytes; - _currentDownloadBytesRaw = 0; - _currentDownLoadBytesDefault = 0; - return EVersionUpdateType.ResUpdate; - } - else - { - Debug.LogError("[LTRes]更新补丁清单失败"); - await _updateUI.ShowDialog("提示", "网络错误"); - return EVersionUpdateType.Error; - } - } - else - { - Debug.LogError("[LTRes]获取服务器CRC失败"); - await _updateUI.ShowDialog("提示", "网络错误"); - return EVersionUpdateType.Error; - } - } - - private void _SaveVersionToLocal() - { - PackDataInst.inst.localInfo.localFullVersion = _serverVersion; - PackDataInst.inst.SaveData(); - } - - public async UniTask UpdateRes() - { - var downloader1 = _downloaderOperation_Default; - downloader1.OnDownloadProgressCallback += _OnProgressChangeDefault; - downloader1.BeginDownload(); - - var downloader2 = _downloaderOperation_Raw; - downloader2.OnDownloadProgressCallback += _OnProgressChangeRaw; - downloader2.BeginDownload(); - - while (!downloader1.IsDone || !downloader1.IsDone) - { - await UniTask.DelayFrame(1); - } - - if (downloader1.Status == EOperationStatus.Succeed - && downloader2.Status == EOperationStatus.Succeed) - { - Debug.Log("[LTRes]下载成功"); - - _SaveVersionToLocal(); - return true; - } - - Debug.LogError($"[LTRes]下载失败:{downloader1.Error}"); - - return false; - } - - private void _OnProgressChangeRaw(int totalDownloadCount, - int currentDownloadCount, - long totalDownloadBytes, - long currentDownloadBytes) - { - _currentDownloadBytesRaw = currentDownloadBytes; - - _UpdateUI(); - } - - private void _UpdateUI() - { - var currentDownloadBytes = _currentDownloadBytesRaw + _currentDownLoadBytesDefault; - var progress = (float)currentDownloadBytes / _totalNeedDownloadBytes; - var progressStr = (progress * 100f).ToString("0.00") + "%"; - // Debug.Log(progressStr); - _updateUI.UpdateProgressText(progressStr); - _updateUI.UpdateProgress(progress); - } - - private void _OnProgressChangeDefault(int totalDownloadCount, - int currentDownloadCount, - long totalDownloadBytes, - long currentDownloadBytes) - { - _currentDownLoadBytesDefault = currentDownloadBytes; - - _UpdateUI(); - } - - public VersionUpdateInfo GetVersionInfo() - { - return _versionInfo; - } - } -} diff --git a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/VersionUpdate_YooAsset.cs.meta b/Forest/Assets/PhxhSDK/AOT/VersionUpdate/VersionUpdate_YooAsset.cs.meta deleted file mode 100644 index 0d5ef24..0000000 --- a/Forest/Assets/PhxhSDK/AOT/VersionUpdate/VersionUpdate_YooAsset.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 00eeef6b6c104d20801654dbe19d0fc5 -timeCreated: 1708580923 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/AOT/YooAsset.meta b/Forest/Assets/PhxhSDK/AOT/YooAsset.meta deleted file mode 100644 index 2a05eea..0000000 --- a/Forest/Assets/PhxhSDK/AOT/YooAsset.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 334ceaaa51174ec199be985764c31ac8 -timeCreated: 1708514105 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/AOT/YooAsset/BuildinFileManifest.cs b/Forest/Assets/PhxhSDK/AOT/YooAsset/BuildinFileManifest.cs deleted file mode 100644 index 85eb412..0000000 --- a/Forest/Assets/PhxhSDK/AOT/YooAsset/BuildinFileManifest.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Collections.Generic; -using UnityEngine; -namespace PhxhSDK.AOT -{ - public class BuildinFileManifest : ScriptableObject - { - public List BuildinFiles = new List(); - } -} diff --git a/Forest/Assets/PhxhSDK/AOT/YooAsset/BuildinFileManifest.cs.meta b/Forest/Assets/PhxhSDK/AOT/YooAsset/BuildinFileManifest.cs.meta deleted file mode 100644 index 2bdc8f9..0000000 --- a/Forest/Assets/PhxhSDK/AOT/YooAsset/BuildinFileManifest.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 56888749a2144af0929c016f5d24356c -timeCreated: 1708514040 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/AOT/YooAsset/CustomFileStream.cs b/Forest/Assets/PhxhSDK/AOT/YooAsset/CustomFileStream.cs deleted file mode 100644 index aba124c..0000000 --- a/Forest/Assets/PhxhSDK/AOT/YooAsset/CustomFileStream.cs +++ /dev/null @@ -1,103 +0,0 @@ -using System.IO; -using UnityEngine; -namespace PhxhSDK.AOT -{ - public class CustomFileStream : Stream - { - - private FileStream _fileStream; - - public CustomFileStream(string path) - { - _fileStream = new FileStream(path, FileMode.Open, FileAccess.Read); - } - - public override void Flush() - { - Debug.LogError("不支持Flush操作"); - } - - public override int Read(byte[] buffer, - int offset, - int count) - { - var read = _fileStream.Read(buffer, offset, count); - for (int i = 0; i < read; i++) - { - // 取反 - var index = offset + i; - buffer[index] = (byte)~buffer[index]; - } - return read; - } - - public override long Seek(long offset, - SeekOrigin origin) - { - return _fileStream.Seek(offset, origin); - } - - public override void SetLength(long value) - { - _fileStream.SetLength(value); - } - - public override void Write(byte[] buffer, - int offset, - int count) - { - Debug.LogError("不支持Write操作"); - } - - public override bool CanRead - { - get - { - return _fileStream.CanRead; - } - } - - public override bool CanSeek - { - get - { - return _fileStream.CanSeek; - } - } - - public override bool CanWrite - { - get - { - return false; - } - } - - public override long Length - { - get - { - return _fileStream.Length; - } - } - - public override long Position - { - get - { - return _fileStream.Position; - } - set - { - _fileStream.Position = value; - } - } - - public override void Close() - { - base.Close(); - _fileStream.Close(); - } - - } -} diff --git a/Forest/Assets/PhxhSDK/AOT/YooAsset/CustomFileStream.cs.meta b/Forest/Assets/PhxhSDK/AOT/YooAsset/CustomFileStream.cs.meta deleted file mode 100644 index c3c3e85..0000000 --- a/Forest/Assets/PhxhSDK/AOT/YooAsset/CustomFileStream.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: b780b30d69794883b021b86a210e69b0 -timeCreated: 1708668162 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/AOT/YooAsset/LTRemoteServices.cs b/Forest/Assets/PhxhSDK/AOT/YooAsset/LTRemoteServices.cs deleted file mode 100644 index 7db7403..0000000 --- a/Forest/Assets/PhxhSDK/AOT/YooAsset/LTRemoteServices.cs +++ /dev/null @@ -1,24 +0,0 @@ -using YooAsset; -namespace PhxhSDK.AOT -{ - public class LTRemoteServices : IRemoteServices - { - - private string _remotePath; - - public LTRemoteServices(string remotePath) - { - _remotePath = remotePath; - } - - public string GetRemoteMainURL(string fileName) - { - return _remotePath + "/" + fileName; - } - - public string GetRemoteFallbackURL(string fileName) - { - return _remotePath + "/" + fileName; - } - } -} diff --git a/Forest/Assets/PhxhSDK/AOT/YooAsset/LTRemoteServices.cs.meta b/Forest/Assets/PhxhSDK/AOT/YooAsset/LTRemoteServices.cs.meta deleted file mode 100644 index 5ce95d2..0000000 --- a/Forest/Assets/PhxhSDK/AOT/YooAsset/LTRemoteServices.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 2ad9a3bb07b74d8dae76fdcc627d42c1 -timeCreated: 1708514573 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/AOT/YooAsset/SteamingAssetHelper.cs b/Forest/Assets/PhxhSDK/AOT/YooAsset/SteamingAssetHelper.cs deleted file mode 100644 index 5e731c6..0000000 --- a/Forest/Assets/PhxhSDK/AOT/YooAsset/SteamingAssetHelper.cs +++ /dev/null @@ -1,136 +0,0 @@ -using System.IO; -using System.Collections.Generic; -using UnityEngine; -using YooAsset; - -namespace PhxhSDK.AOT -{ - - - /// - /// 资源文件查询服务类 - /// - public class GameQueryServices : IBuildinQueryServices - { - public bool Query(string packageName, - string fileName, - string fileCRC) - { - // 注意:fileName包含文件格式 - return StreamingAssetsHelper.FileExists(packageName, fileName); - } - } - - public class GameDeliveryServices : IDeliveryQueryServices - { - public bool Query(string packageName, - string fileName, - string fileCRC) - { - return false; - } - public string GetFilePath(string packageName, - string fileName) - { - throw new System.NotImplementedException(); - } - } - -#if UNITY_EDITOR - /// - /// StreamingAssets目录下资源查询帮助类 - /// - public sealed class StreamingAssetsHelper - { - public static void Init() {} - public static bool FileExists(string packageName, - string fileName) - { - string filePath = Path.Combine(Application.streamingAssetsPath, StreamingAssetsDefine.RootFolderName, packageName, fileName); - return File.Exists(filePath); - } - } -#else -/// -/// StreamingAssets目录下资源查询帮助类 -/// -public sealed class StreamingAssetsHelper -{ - private static bool _isInit = false; - private static readonly HashSet _cacheData = new HashSet(); - - /// - /// 初始化 - /// - public static void Init() - { - if (_isInit == false) - { - _isInit = true; - var manifest = Resources.Load("BuildinFileManifest"); - if (manifest != null) - { - foreach (string fileName in manifest.BuildinFiles) - { - _cacheData.Add(fileName); - } - } - } - } - - /// - /// 内置文件查询方法 - /// - public static bool FileExists(string packageName, string fileName) - { - if (_isInit == false) - Init(); - return _cacheData.Contains(fileName); - } -} -#endif - - -#if UNITY_EDITOR - internal class PreprocessBuild : UnityEditor.Build.IPreprocessBuildWithReport - { - public int callbackOrder { get { return 0; } } - - /// - /// 在构建应用程序前处理 - /// - public void OnPreprocessBuild(UnityEditor.Build.Reporting.BuildReport report) - { - string saveFilePath = "Assets/Resources/BuildinFileManifest.asset"; - if (File.Exists(saveFilePath)) - File.Delete(saveFilePath); - - string folderPath = $"{Application.dataPath}/StreamingAssets/{StreamingAssetsDefine.RootFolderName}"; - DirectoryInfo root = new DirectoryInfo(folderPath); - if (root.Exists == false) - { - Debug.Log($"没有发现YooAsset内置目录 : {folderPath}"); - return; - } - - var manifest = ScriptableObject.CreateInstance(); - FileInfo[] files = root.GetFiles("*", SearchOption.AllDirectories); - foreach (var fileInfo in files) - { - if (fileInfo.Extension == ".meta") - continue; - if (fileInfo.Name.StartsWith("PackageManifest_")) - continue; - manifest.BuildinFiles.Add(fileInfo.Name); - } - - if (Directory.Exists("Assets/Resources") == false) - Directory.CreateDirectory("Assets/Resources"); - UnityEditor.AssetDatabase.CreateAsset(manifest, saveFilePath); - UnityEditor.AssetDatabase.SaveAssets(); - UnityEditor.AssetDatabase.Refresh(); - Debug.Log($"一共{manifest.BuildinFiles.Count}个内置文件,内置资源清单保存成功 : {saveFilePath}"); - } - } -#endif -} diff --git a/Forest/Assets/PhxhSDK/AOT/YooAsset/SteamingAssetHelper.cs.meta b/Forest/Assets/PhxhSDK/AOT/YooAsset/SteamingAssetHelper.cs.meta deleted file mode 100644 index 4cdefe0..0000000 --- a/Forest/Assets/PhxhSDK/AOT/YooAsset/SteamingAssetHelper.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: e22d54ed66a149198e471736a4e537d7 -timeCreated: 1708513920 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/AOT/YooAsset/StreamingAssetsDefine.cs b/Forest/Assets/PhxhSDK/AOT/YooAsset/StreamingAssetsDefine.cs deleted file mode 100644 index 8cccbc4..0000000 --- a/Forest/Assets/PhxhSDK/AOT/YooAsset/StreamingAssetsDefine.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace PhxhSDK.AOT -{ - public class StreamingAssetsDefine - { - public const string RootFolderName = "yoo"; - } -} diff --git a/Forest/Assets/PhxhSDK/AOT/YooAsset/StreamingAssetsDefine.cs.meta b/Forest/Assets/PhxhSDK/AOT/YooAsset/StreamingAssetsDefine.cs.meta deleted file mode 100644 index d836d5a..0000000 --- a/Forest/Assets/PhxhSDK/AOT/YooAsset/StreamingAssetsDefine.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 3cd0086ebeeb48d0bbad9622c5c577b8 -timeCreated: 1708514012 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/AOT/YooAsset/YooAssetBuildStatus.cs b/Forest/Assets/PhxhSDK/AOT/YooAsset/YooAssetBuildStatus.cs deleted file mode 100644 index f37faee..0000000 --- a/Forest/Assets/PhxhSDK/AOT/YooAsset/YooAssetBuildStatus.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace PhxhSDK.AOT -{ - public static class YooAssetBuildStatus - { - public static bool isInBuild = false; - } -} diff --git a/Forest/Assets/PhxhSDK/AOT/YooAsset/YooAssetBuildStatus.cs.meta b/Forest/Assets/PhxhSDK/AOT/YooAsset/YooAssetBuildStatus.cs.meta deleted file mode 100644 index 0577f95..0000000 --- a/Forest/Assets/PhxhSDK/AOT/YooAsset/YooAssetBuildStatus.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 0982954dec7e4817aacc6acdf44b9cf3 -timeCreated: 1708490336 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/AOT/YooAsset/YooAssetHelper.cs b/Forest/Assets/PhxhSDK/AOT/YooAsset/YooAssetHelper.cs deleted file mode 100644 index 8f61bfa..0000000 --- a/Forest/Assets/PhxhSDK/AOT/YooAsset/YooAssetHelper.cs +++ /dev/null @@ -1,116 +0,0 @@ -using Cysharp.Threading.Tasks; -using PhxhSDK.AOT.VersionUpdate; -using UnityEngine; -using YooAsset; -namespace PhxhSDK.AOT -{ - public class YooAssetHelper - { - public static ResourcePackage defaultPackage; - public static ResourcePackage rawPackage; - - public static async UniTask Init() - { - if (defaultPackage != null) return; - // 初始化资源系统 - YooAssets.Initialize(); - - // 创建默认的资源包 - defaultPackage = YooAssets.CreatePackage("DefaultPackage"); - rawPackage = YooAssets.CreatePackage("RawPackage"); - - // 设置该资源包为默认的资源包,可以使用YooAssets相关加载接口加载该资源包内容。 - YooAssets.SetDefaultPackage(defaultPackage); - -#if UNITY_EDITOR - #if AB_DEBUG - await _InitRemote(); - #else - await _InitEditor(); - #endif -#else - await _InitRemote(); -#endif - } - - private static async UniTask _InitEditor() - { - Debug.Log("[LTRes]开始初始化编辑器模拟模式"); - var initParametersDefault = new EditorSimulateModeParameters(); - initParametersDefault.AutoDestroyAssetProvider = true; - initParametersDefault.SimulateManifestFilePath = EditorSimulateModeHelper.SimulateBuild(EDefaultBuildPipeline.BuiltinBuildPipeline, "DefaultPackage"); - var op = defaultPackage.InitializeAsync(initParametersDefault); - await op.Task; - if (op.Status != EOperationStatus.Succeed) - { - Debug.LogError("[LTRes]初始化编辑器模拟模式失败"); - return false; - } - var initParametersRaw = new EditorSimulateModeParameters(); - initParametersRaw.AutoDestroyAssetProvider = true; - initParametersRaw.SimulateManifestFilePath = EditorSimulateModeHelper.SimulateBuild(EDefaultBuildPipeline.RawFileBuildPipeline, "RawPackage"); - var op2 = rawPackage.InitializeAsync(initParametersRaw); - await op2.Task; - if (op2.Status != EOperationStatus.Succeed) - { - Debug.LogError("[LTRes]初始化编辑器模拟模式失败"); - return false; - } - return true; - } - - public static async UniTask InitEditor() - { - await _InitEditor(); - } - - private static async UniTask _InitRemote() - { - if (!_isInit) - { - _isInit = true; - await _InitPackage(defaultPackage, false); - await _InitPackage(rawPackage, true); - Debug.Log("[LTRes]InitializeAsync 完成"); - } - else - { - Debug.Log("[LTRes]开始重新尝试初始化remote load"); - } - - return true; - } - - private static bool _isInit = false; - private static async UniTask _InitPackage(ResourcePackage package, bool noEncrypt) - { - Debug.Log("开始初始化package:" + package); - var initParameters = new HostPlayModeParameters(); - initParameters.AutoDestroyAssetProvider = true; - initParameters.BuildinQueryServices = new GameQueryServices(); - // initParameters.DeliveryQueryServices = new GameDeliveryServices(); - if (noEncrypt) - { - initParameters.DecryptionServices = new YooDecryptionNone(); - } - else - { - initParameters.DecryptionServices = new YooDecryptionFS(); - } - - PackDataInst.CreateInst(); - var workSpace = PackDataInst.inst.localInfo.workSpace; - var version = PackDataInst.inst.localInfo.version; - var buildTarget = PackDataInst.GetRuntimePlatform(); - var serverUrl = PackDataInst.inst.localInfo.serverUrl; - var pathRoot = PackDataInst.inst.localInfo.pathRoot; - var hostPath = $"{serverUrl}/{pathRoot}/{workSpace}/{buildTarget}/{version}"; - initParameters.RemoteServices = new LTRemoteServices(hostPath); - - await package.InitializeAsync(initParameters).Task; - Debug.Log("初始化package结束:" + package); - } - - - } -} diff --git a/Forest/Assets/PhxhSDK/AOT/YooAsset/YooAssetHelper.cs.meta b/Forest/Assets/PhxhSDK/AOT/YooAsset/YooAssetHelper.cs.meta deleted file mode 100644 index 5828539..0000000 --- a/Forest/Assets/PhxhSDK/AOT/YooAsset/YooAssetHelper.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: a783ee08288c46c799a5f409eb5c65ea -timeCreated: 1708495618 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/AOT/YooAsset/YooDecryptionFS.cs b/Forest/Assets/PhxhSDK/AOT/YooAsset/YooDecryptionFS.cs deleted file mode 100644 index 98518fc..0000000 --- a/Forest/Assets/PhxhSDK/AOT/YooAsset/YooDecryptionFS.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.IO; -using UnityEngine; -using YooAsset; -namespace PhxhSDK.AOT -{ - public class YooDecryptionFS : IDecryptionServices - { - - public AssetBundle LoadAssetBundle(DecryptFileInfo fileInfo, - out Stream managedStream) - { - managedStream = new CustomFileStream(fileInfo.FileLoadPath); - return AssetBundle.LoadFromStream(managedStream); - } - - public AssetBundleCreateRequest LoadAssetBundleAsync(DecryptFileInfo fileInfo, - out Stream managedStream) - { - managedStream = new CustomFileStream(fileInfo.FileLoadPath); - return AssetBundle.LoadFromStreamAsync(managedStream); - } - - } -} diff --git a/Forest/Assets/PhxhSDK/AOT/YooAsset/YooDecryptionFS.cs.meta b/Forest/Assets/PhxhSDK/AOT/YooAsset/YooDecryptionFS.cs.meta deleted file mode 100644 index a70a48a..0000000 --- a/Forest/Assets/PhxhSDK/AOT/YooAsset/YooDecryptionFS.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 06fb2e9ce57845f0bdabda7c756334ba -timeCreated: 1708668451 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/AOT/YooAsset/YooDecryptionNone.cs b/Forest/Assets/PhxhSDK/AOT/YooAsset/YooDecryptionNone.cs deleted file mode 100644 index 5fa6b08..0000000 --- a/Forest/Assets/PhxhSDK/AOT/YooAsset/YooDecryptionNone.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.IO; -using UnityEngine; -using YooAsset; -namespace PhxhSDK.AOT -{ - public class YooDecryptionNone : IDecryptionServices - { - - public AssetBundle LoadAssetBundle(DecryptFileInfo fileInfo, - out Stream managedStream) - { - managedStream = new FileStream(fileInfo.FileLoadPath, FileMode.Open, FileAccess.Read); - return AssetBundle.LoadFromStream(managedStream); - } - public AssetBundleCreateRequest LoadAssetBundleAsync(DecryptFileInfo fileInfo, - out Stream managedStream) - { - managedStream = new FileStream(fileInfo.FileLoadPath, FileMode.Open, FileAccess.Read); - return AssetBundle.LoadFromStreamAsync(managedStream); - } - } -} diff --git a/Forest/Assets/PhxhSDK/AOT/YooAsset/YooDecryptionNone.cs.meta b/Forest/Assets/PhxhSDK/AOT/YooAsset/YooDecryptionNone.cs.meta deleted file mode 100644 index b2cbac6..0000000 --- a/Forest/Assets/PhxhSDK/AOT/YooAsset/YooDecryptionNone.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 540fa3c1015f486aa3be05a496c9d170 -timeCreated: 1708514119 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor.meta b/Forest/Assets/PhxhSDK/Editor.meta deleted file mode 100644 index 10d4c29..0000000 --- a/Forest/Assets/PhxhSDK/Editor.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 3f290986483554bde92a8a36ddc1704a -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor.meta b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor.meta deleted file mode 100644 index a6af096..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: c12723bd0454c41b4806ab3381cff9a7 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Material.meta b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Material.meta deleted file mode 100644 index dd644ce..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Material.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: cee1b9a78f7514d5ba92ac5e927f489e -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Material/MaterialImportSettings.cs b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Material/MaterialImportSettings.cs deleted file mode 100644 index 5b75e77..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Material/MaterialImportSettings.cs +++ /dev/null @@ -1,104 +0,0 @@ -using System; -using System.Collections.Generic; -using Sirenix.OdinInspector; -using UnityEngine; - -[Serializable] -[CreateAssetMenu(fileName = "MaterialImportSettings", menuName = "AssetImportSettings/MaterialImportSettings", - order = 0)] -public class MaterialImportSettings : ScriptableObject -{ - private static bool _isDirtyLock = true; - - [LabelText("Material设置")] public List settings; - - public static bool IsDirtyLock - { - set => _isDirtyLock = value; - get - { - var r = _isDirtyLock; - _isDirtyLock = false; - return r; - } - } - - [Button] - public void Save() - { - IsDirtyLock = true; - } -} - -[Serializable] -public class MaterialImportSetting -{ - public const string MaterialImportSettingsPath = "Assets/Editor/Settings/MaterialImportSettings.asset"; - - public static string ExcludePostFix = "_CC"; - public static string NameFormatNone = "-"; - - public static readonly string[] NameFormatPre = - { - NameFormatNone, // none, dont move - - "M_A", - "M_B", - "M_C", - "M_E", - "M_G", - "M_N", - "M_S" - }; - - public static readonly string[] NameFormatPost = - { - NameFormatNone, // none, dont move - - "_bar", - "_cw", - "_bow", - "_dmr", - "_ar", - "_sg", - "_lmg", - "_hf", - "_mg" - }; - - public string name; - - - [LabelText("名前缀")] [ValueDropdown("NameFormatPre")] - public string PreFix; - - [LabelText("名后缀")] [ValueDropdown("NameFormatPost")] - public string PostFix; - - - [ValueDropdown("AllShaderNames")] public string shaderName; - - [ShowIf("shaderName", "NLD_URP/NLD_Charactor")] - public string outlineColorName; - - [ShowIf("shaderName", "NLD_URP/NLD_Charactor")] - public Color outlineColor; - - [ShowIf("shaderName", "NLD_URP/NLD_Charactor")] - public string thickOfOutlineName; - - [ShowIf("shaderName", "NLD_URP/NLD_Charactor")] [Range(0, 0.1f)] - public float thickOfOutline; - - [ShowIf("shaderName", "NLD_URP/NLD_Charactor")] - public string factorName; - - [ShowIf("shaderName", "NLD_URP/NLD_Charactor")] [Range(0, 1f)] - public float factor; - - - public string[] AllShaderNames = - { - "NLD_URP/NLD_Charactor" - }; -} \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Material/MaterialImportSettings.cs.meta b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Material/MaterialImportSettings.cs.meta deleted file mode 100644 index 6563a20..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Material/MaterialImportSettings.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1d33b14a14b99496e8c62e98e0cbf523 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Material/MaterialsPostprocessor.cs b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Material/MaterialsPostprocessor.cs deleted file mode 100644 index 8b8caa1..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Material/MaterialsPostprocessor.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.IO; -using UnityEditor; -using UnityEngine; - -public class MaterialsPostprocessor : AssetPostprocessor -{ - private static MaterialImportSettings config; - - private void OnPostprocessMaterial(Material material) - { - UpdateMaterialSettings(); - - if (config == null) return; - - var fileName = GetFileName(assetPath); - - if (fileName.EndsWith(MaterialImportSetting.ExcludePostFix)) return; - - - var settings = config.settings.Find(set => set.PreFix != MaterialImportSetting.NameFormatNone - && fileName.StartsWith(set.PreFix) - && - (set.PostFix == MaterialImportSetting.NameFormatNone - || fileName.EndsWith(set.PostFix))); - - - if (settings != null) - { - material.SetColor(settings.outlineColorName, settings.outlineColor); - material.SetFloat(settings.thickOfOutlineName, settings.thickOfOutline); - material.SetFloat(settings.factorName, settings.factor); - } - } - - private void UpdateMaterialSettings() - { - if (config == null || MaterialImportSettings.IsDirtyLock) - { - config = - AssetDatabase.LoadAssetAtPath(MaterialImportSetting.MaterialImportSettingsPath); - if (config == null) Debug.LogError("material format config is null"); - } - } - - - private string GetFileName(string assetPath) - { - return Path.GetFileNameWithoutExtension(assetPath); - } -} \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Material/MaterialsPostprocessor.cs.meta b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Material/MaterialsPostprocessor.cs.meta deleted file mode 100644 index 8e620c2..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Material/MaterialsPostprocessor.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 85e015d9b1baf4521999c8366748fedd -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Model.meta b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Model.meta deleted file mode 100644 index 37f0681..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Model.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 595ddfe0ba6d143879db141104269478 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Model/ModelImportSettings.cs b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Model/ModelImportSettings.cs deleted file mode 100644 index 3c6187e..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Model/ModelImportSettings.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.Collections.Generic; -using UnityEditor; -using UnityEngine; - -[Serializable] -[CreateAssetMenu(fileName = "ModelImportSetting", menuName = "AssetImportSettings/ModelSettings", order = 0)] -public class ModelImportSettings : ScriptableObject -{ - public ModelImportSetting defaultImportSetting; - public List settings; -} - -[Serializable] -public class ModelImportSetting -{ - public enum BasedUpon - { - Original - } - - public enum NameFormatPost - { - none - } - - - public enum NameFormatPre - { - none - } - - public string Name; - public NameFormatPre PreFix; - public NameFormatPost PostFix; - - - public bool rootRotationBakeIntoPose; - public BasedUpon rootRotationBasedUpon; - public bool rootPositionYBakeIntoPose; - public BasedUpon rootPositionYBasedUpon; - public bool rootPositionXZBakeIntoPose; - public BasedUpon rootPositionXZBasedUpon; - - - public ModelImporterAnimationCompression animationCompression; -} \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Model/ModelImportSettings.cs.meta b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Model/ModelImportSettings.cs.meta deleted file mode 100644 index 867f9d7..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Model/ModelImportSettings.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ec2265d5373f3404c8ecdc99113af95e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Model/ModelPostProcessor.cs b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Model/ModelPostProcessor.cs deleted file mode 100644 index 7d792a5..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Model/ModelPostProcessor.cs +++ /dev/null @@ -1,69 +0,0 @@ -using UnityEditor; -using UnityEngine; - -public class ModelPostProcessor : AssetPostprocessor -{ - private void OnPreprocessModel() - { - var config = - AssetDatabase.LoadAssetAtPath("Assets/Editor/Settings/ModelImportSetting.asset"); - if (config == null) - { - Debug.LogError("Model format config is null"); - return; - } - - var importer = assetImporter as ModelImporter; - - var fileName = GetFileName(importer.assetPath); - - // if (fileName.EndsWith("_cc")) - // { - // return; - // } - - var settings = config.settings.Find(set => - (set.PreFix != ModelImportSetting.NameFormatPre.none && - fileName.ToLower().StartsWith(set.PreFix.ToString().ToLower())) || - (set.PostFix != ModelImportSetting.NameFormatPost.none && - fileName.ToLower().EndsWith(set.PostFix.ToString().ToLower()))); - - - if (settings == null) - { - var animations = importer.clipAnimations; - if (animations != null) - for (var i = 0; i < animations.Length; i++) - SetAnimation(animations[i], config.defaultImportSetting); - - importer.clipAnimations = animations; - importer.animationCompression = config.defaultImportSetting.animationCompression; - importer.SaveAndReimport(); - } - } - - private void SetAnimation(ModelImporterClipAnimation animation, ModelImportSetting importSetting) - { - animation.keepOriginalOrientation = - importSetting.rootRotationBasedUpon == ModelImportSetting.BasedUpon.Original; - animation.lockRootRotation = importSetting.rootRotationBakeIntoPose; - - animation.keepOriginalPositionY = importSetting.rootPositionYBasedUpon == ModelImportSetting.BasedUpon.Original; - animation.lockRootHeightY = importSetting.rootPositionYBakeIntoPose; - - - animation.keepOriginalPositionXZ = - importSetting.rootPositionXZBasedUpon == ModelImportSetting.BasedUpon.Original; - animation.lockRootPositionXZ = importSetting.rootPositionXZBakeIntoPose; - } - - - private string GetFileName(string assetPath) - { - var fileName = assetPath.Remove(0, assetPath.LastIndexOf('/') + 1); - var pointIndex = fileName.LastIndexOf('.'); - fileName = fileName.Remove(pointIndex, fileName.Length - pointIndex); - - return fileName; - } -} \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Model/ModelPostProcessor.cs.meta b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Model/ModelPostProcessor.cs.meta deleted file mode 100644 index d10c7ff..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Model/ModelPostProcessor.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c0058c62bd07b4105aaabff7a6144da5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Prefab.meta b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Prefab.meta deleted file mode 100644 index 8134c81..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Prefab.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 572b9c54ed20b40439605f545b6e05a2 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Prefab/AssetProcessEditor.cs b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Prefab/AssetProcessEditor.cs deleted file mode 100644 index da17ffe..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Prefab/AssetProcessEditor.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Sirenix.OdinInspector; -using Sirenix.OdinInspector.Editor; -using Sirenix.Utilities; -using Sirenix.Utilities.Editor; -using UnityEditor; - -public class AssetProcessEditor : OdinMenuEditorWindow -{ - [MenuItem("Tools/AssetProcessEditor")] - private static void OpenWindow() - { - var window = GetWindow(); - window.position = GUIHelper.GetEditorWindowRect().AlignCenter(800, 600); - } - - protected override OdinMenuTree BuildMenuTree() - { - var tree = new OdinMenuTree(true) - { - { - "Home", PrefabTools.Instance, SdfIconType.Box - }, - { - "Setting", null, SdfIconType.Gear - } - }; - - tree.AddAssetAtPath("Setting/Prefab", PrefabImportSetting.PrefabImportSettingsPath); - - // As you can see, Odin provides a few ways to quickly add editors / objects to your menu tree. - // The API also gives you full control over the selection, etc.. - // Make sure to check out the API Documentation for OdinMenuEditorWindow, OdinMenuTree and OdinMenuItem for more information on what you can do! - - return tree; - } -} \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Prefab/AssetProcessEditor.cs.meta b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Prefab/AssetProcessEditor.cs.meta deleted file mode 100644 index e6fd4ee..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Prefab/AssetProcessEditor.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1180e461b5b3e462ca3fa75143369233 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Prefab/PrefabImportSettings.cs b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Prefab/PrefabImportSettings.cs deleted file mode 100644 index d0d8c49..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Prefab/PrefabImportSettings.cs +++ /dev/null @@ -1,103 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using Sirenix.OdinInspector; -using UnityEngine; - -[Serializable] -[CreateAssetMenu(fileName = "PrefabImportSettings", menuName = "AssetImportSettings/PrefabImportSettings", order = 0)] -public class PrefabImportSettings : ScriptableObject -{ - [LabelText("Prefab规则")] public List settings; - - [Button] - public void AddSetting() - { - } -} - -[Serializable] -public class PrefabImportSetting -{ - public const string PrefabImportSettingsPath = "Assets/Editor/Settings/PrefabImportSettings.asset"; - - public static string ExcludePostFix = "_CC"; - public static string NameFormatNone = "-"; - - public static readonly string[] NameFormatPre = - { - NameFormatNone, // none, dont move - - "P_A", - "P_B", - "P_C", - "P_E", - "P_G", - "P_N", - "P_S", - - "Skill_", - "Bullet_" - }; - - public static readonly string[] NameFormatPost = - { - NameFormatNone, // none, dont move - - "_bar", - "_cw", - "_bow", - "_dmr", - "_ar", - "_sg", - "_lmg", - "_hf", - "_mg" - }; - - public string name; - - - [LabelText("名前缀")] [ValueDropdown("NameFormatPre")] - public string PreFix; - - [LabelText("名后缀")] [ValueDropdown("NameFormatPost")] - public string PostFix; - - - [ValueDropdown("AllLayerNames")] public int layer; - - - [LabelText("绑胶囊体")] public bool bindCapsuleCollider; - - [ShowIf("bindCapsuleCollider")] public float radius; - - [ShowIf("bindCapsuleCollider")] public float height; - - [ShowIf("bindCapsuleCollider")] public Vector3 center; - - - [LabelText("处理SkinnedMeshRenderer")] public bool processSkinnedMeshRenderer; - - [ShowIf("processSkinnedMeshRenderer")] public bool skinnedMotionVectors; - - [LabelText("处理particle system")] public bool processParticlesSystem; - - [ShowIf("processParticlesSystem")] public int maxParticles = 50; - - public IEnumerable AllLayerNames() - { - var list = new ValueDropdownList(); - - var totalLayers = 32; // Unity supports 32 layers by default - // Loop through each layer and get its name - for (var i = 0; i < totalLayers; i++) - { - var layerName = LayerMask.LayerToName(i); - // Check if the layer name is not empty (i.e., it is defined) - if (!string.IsNullOrEmpty(layerName)) list.Add(layerName, i); - } - - return list; - } -} \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Prefab/PrefabImportSettings.cs.meta b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Prefab/PrefabImportSettings.cs.meta deleted file mode 100644 index f036b87..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Prefab/PrefabImportSettings.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8bc2d05bc013943f3836a4462e767326 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Prefab/PrefabTools.cs b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Prefab/PrefabTools.cs deleted file mode 100644 index 532d6fd..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Prefab/PrefabTools.cs +++ /dev/null @@ -1,154 +0,0 @@ -using System; -using Sirenix.OdinInspector; -using UnityEditor; -using UnityEngine; - -[Serializable] -public class PrefabTools -{ - private static PrefabTools _instance; - - public static PrefabTools Instance - { - get - { - if (_instance == null) _instance = new PrefabTools(); - - return _instance; - } - } - - [Button] - public void ProcessAll() - { - _ProcessPrefabs(); - } - - private void _ProcessTexture2Ds() - { - var allT2DGUIDs = AssetDatabase.FindAssets("t:Texture2D", new[] { "Assets/Art" }); - for (var i = 0; i < allT2DGUIDs.Length; i++) - { - var guid = allT2DGUIDs[i]; - var assetPath = AssetDatabase.GUIDToAssetPath(guid); - _ProcessTexture2D(assetPath); - } - } - - private void _ProcessPrefabs() - { - try - { - var allPrefabs = AssetDatabase.FindAssets("t:Prefab", new[] { "Assets/Art" }); - - for (var i = 0; i < allPrefabs.Length; i++) - { - var guid = allPrefabs[i]; - var assetPath = AssetDatabase.GUIDToAssetPath(guid); - var gameObject = AssetDatabase.LoadAssetAtPath(assetPath); - if (gameObject != null) ProcessPrefab(gameObject, assetPath); - } - } - catch (Exception e) - { - Debug.LogException(e); - } - } - - private static void _ProcessTexture2D(string assetPath) - { - var texture2D = AssetDatabase.LoadAssetAtPath(assetPath); - if (texture2D == null) return; - var importer = AssetImporter.GetAtPath(assetPath) as TextureImporter; - } - - - public static void ProcessPrefab(GameObject go, string assetPath) - { - if (go == null) - { - Debug.LogError($"Prefab is null, assetPath = {assetPath}"); - return; - } - - var config = AssetDatabase.LoadAssetAtPath(PrefabImportSetting.PrefabImportSettingsPath); - if (config == null) - { - Debug.LogError("Prefab Import config is null"); - return; - } - - - var fileName = GetFileName(assetPath); - - if (fileName.EndsWith(PrefabImportSetting.ExcludePostFix)) return; - // 同时满足前缀后缀 - var settings = config.settings.Find(set => set.PreFix != PrefabImportSetting.NameFormatNone - && fileName.StartsWith(set.PreFix) - && - set.PostFix != PrefabImportSetting.NameFormatNone - && fileName.EndsWith(set.PostFix)); - - // 前缀后缀满足其一 - if (settings == null) - settings = config.settings.Find(set => ( - set.PreFix != PrefabImportSetting.NameFormatNone - && fileName.StartsWith(set.PreFix)) - || - (set.PostFix != PrefabImportSetting.NameFormatNone - && fileName.EndsWith(set.PostFix))); - - // 默认设置 - if (settings == null) - settings = config.settings.Find(set => fileName.StartsWith(PrefabImportSetting.NameFormatNone) - && - fileName.EndsWith(PrefabImportSetting.NameFormatNone)); - - - if (settings != null) - { - if (settings.bindCapsuleCollider) - if (go.GetComponent() == null) - { - var capsuleCollider = go.AddComponent(); - capsuleCollider.radius = settings.radius; - capsuleCollider.center = settings.center; - capsuleCollider.height = settings.height; - } - - go.layer = settings.layer; - - if (settings.processSkinnedMeshRenderer) - { - var smrs = go.GetComponentsInChildren(); - if (smrs != null) - for (var i = 0; i < smrs.Length; i++) - smrs[i].skinnedMotionVectors = settings.skinnedMotionVectors; - } - - if (settings.processParticlesSystem) - { - var pss = go.GetComponentsInChildren(); - if (pss != null) - for (var i = 0; i < pss.Length; i++) - { - var ps = pss[i]; - ps.maxParticles = settings.maxParticles; - } - } - - // VersionControlSystem.Checkout(assetPath); - PrefabUtility.SavePrefabAsset(go); - // VersionControlSystem.Revert(assetPath, RevertMode.Unchanged); - } - } - - private static string GetFileName(string assetPath) - { - var fileName = assetPath.Remove(0, assetPath.LastIndexOf('/') + 1); - var pointIndex = fileName.LastIndexOf('.'); - fileName = fileName.Remove(pointIndex, fileName.Length - pointIndex); - - return fileName; - } -} \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Prefab/PrefabTools.cs.meta b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Prefab/PrefabTools.cs.meta deleted file mode 100644 index 31696a4..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Prefab/PrefabTools.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 9a0edacf4f6b46e5b2b59d9b2a9f1e51 -timeCreated: 1690528911 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture.meta b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture.meta deleted file mode 100644 index e97b510..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 86d4e4f851d494ba68f47daa0153d149 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture/TextureFormatSetting.Const.cs b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture/TextureFormatSetting.Const.cs deleted file mode 100644 index a5fda4f..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture/TextureFormatSetting.Const.cs +++ /dev/null @@ -1,63 +0,0 @@ -public static class TextureFormatSettingConst -{ - public const string TextureFormatSettingsPath = "Assets/Editor/Settings/TextureFormatSettings.asset"; - - public static string ExcludePostFix = "_CC"; - public static string NameFormatNone = "-"; - - public static readonly string[] NameFormatPre = - { - NameFormatNone, // none, dont move - - "UI_", - "BG_", - - "Poster_", - "Icon_", - "Gfx_", - "T_A", - "T_E", - "T_G", - "T_C", - "T_B", - "T_emoji", - "T_S", - "T_emoji_lian_", - "T_F", - "Map", - "split", - "Skybox_", - "Combie" - }; - - public static readonly string[] NameFormatPost = - { - NameFormatNone, // none, dont move - - "_slh", - "_mask", - "_d", - "_surface" - }; - - public static readonly string[] EndDress = - { - NameFormatNone, - - ".jpg", - ".png" - }; - - public static readonly string[] TextureMaxSize = - { - "32", - "64", - "128", - "256", - "512", - "1024", - "2048", - "4096", - "8192" - }; -} \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture/TextureFormatSetting.Const.cs.meta b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture/TextureFormatSetting.Const.cs.meta deleted file mode 100644 index 4098abe..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture/TextureFormatSetting.Const.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b8956928438d341afaa07921ffcd9f8a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture/TextureFormatSettingInspector.cs b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture/TextureFormatSettingInspector.cs deleted file mode 100644 index a99514b..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture/TextureFormatSettingInspector.cs +++ /dev/null @@ -1,135 +0,0 @@ -using System; -using System.Collections.Generic; -using UnityEditor; -using UnityEngine; - -[CustomEditor(typeof(TextureFormatSettings))] -public class TextureFormatSettingInspector : Editor -{ - private TextureFormatSettings targetSettings; - - - public void OnEnable() - { - targetSettings = target as TextureFormatSettings; - } - - public override void OnInspectorGUI() - { - EditorGUILayout.LabelField("排除后缀为", TextureFormatSettingConst.ExcludePostFix); - - - for (var i = 0; i < targetSettings.settings.Count; i++) - { - var setting = targetSettings.settings[i]; - using (new EditorGUILayout.HorizontalScope()) - { - setting.Name = EditorGUILayout.TextField("种类", setting.Name); - if (GUILayout.Button("↑") && i > 0) - { - targetSettings.settings[i] = targetSettings.settings[i - 1]; - targetSettings.settings[i - 1] = setting; - } - - if (GUILayout.Button("↓") && i < targetSettings.settings.Count - 1) - { - targetSettings.settings[i] = targetSettings.settings[i + 1]; - targetSettings.settings[i + 1] = setting; - } - - if (GUILayout.Button("删")) - { - for (var j = i + 1; j < targetSettings.settings.Count; j++) - targetSettings.settings[j - 1] = targetSettings.settings[j]; - targetSettings.settings.RemoveAt(targetSettings.settings.Count - 1); - setting = targetSettings.settings[i]; - } - } - - setting.InspectorFoldOut = EditorGUILayout.Foldout(setting.InspectorFoldOut, ""); - if (setting.InspectorFoldOut) - { - setting.PreFix = EditorGUILayoutPopup("前缀", setting.PreFix, TextureFormatSettingConst.NameFormatPre); - setting.PostFix = EditorGUILayoutPopup("后缀", setting.PostFix, TextureFormatSettingConst.NameFormatPost); - setting.EndDress = EditorGUILayoutPopup("文件类型", setting.EndDress, TextureFormatSettingConst.EndDress); - - setting.ImporterType = - (TextureImporterType)EditorGUILayout.EnumPopup("Texture Type", setting.ImporterType); - setting.ImporterShape = - (TextureImporterShape)EditorGUILayout.EnumPopup("Texture Shape", setting.ImporterShape); - setting.GeneratePhysicShape = - EditorGUILayout.Toggle("Generate Physic Shape", setting.GeneratePhysicShape); - setting.MaxSize = int.Parse(EditorGUILayoutPopup("Max Size", setting.MaxSize.ToString(), - TextureFormatSettingConst.TextureMaxSize)); - setting.StandaloneMaxSize = int.Parse(EditorGUILayoutPopup("standalone max size", - setting.StandaloneMaxSize.ToString(), TextureFormatSettingConst.TextureMaxSize)); - setting.MipMap = EditorGUILayout.Toggle("Mip Maps", setting.MipMap); - setting.ForceAlphaSetting = EditorGUILayout.Toggle("force alpha", setting.ForceAlphaSetting); - setting.Alpha = (TextureImporterAlphaSource)EditorGUILayout.EnumPopup("alpha source", setting.Alpha); - setting.WrapMode = (TextureWrapMode)EditorGUILayout.EnumPopup("wrap mode", setting.WrapMode); - setting.IsReadable = EditorGUILayout.Toggle("is readable", setting.IsReadable); - setting.FilterMode = (FilterMode)EditorGUILayout.EnumPopup("filter mode", setting.FilterMode); - setting.NPOT = (TextureImporterNPOTScale)EditorGUILayout.EnumPopup("Non-Power of 2", setting.NPOT); - - setting.FormatIos = (TextureImporterFormat)EditorGUILayout.EnumPopup("IOS Format", setting.FormatIos); - setting.FormatAndroid = - (TextureImporterFormat)EditorGUILayout.EnumPopup("Android Format", setting.FormatAndroid); - setting.FormatIosAlpha = - (TextureImporterFormat)EditorGUILayout.EnumPopup("IOS Alpha Format", setting.FormatIosAlpha); - setting.FormatAndroidAlpha = - (TextureImporterFormat)EditorGUILayout.EnumPopup("Android Alpha Format", - setting.FormatAndroidAlpha); - setting.FormatStandalone = - (TextureImporterFormat)EditorGUILayout.EnumPopup("Standalone Format", setting.FormatStandalone); - setting.FormatStandaloneAlpha = - (TextureImporterFormat)EditorGUILayout.EnumPopup("Standalone Alpha Format", - setting.FormatStandaloneAlpha); - } - - EditorGUILayout.Separator(); - EditorGUILayout.Separator(); - EditorGUILayout.Separator(); - EditorGUILayout.Separator(); - } - - if (GUILayout.Button("+")) targetSettings.settings.Add(new TextureFormatSetting { Name = "未知" }); - - TextureFormatSettings.IsDirtyLock = true; - EditorUtility.SetDirty(targetSettings); - - using (new EditorGUILayout.HorizontalScope()) - { - if (GUILayout.Button("Save")) - { - } - - if (GUILayout.Button("ReImport All Textures")) - { - } - } - } - - private int FindIndex(IReadOnlyList collection, T value) - { - if (collection != null) - for (var i = 0; i < collection.Count; i++) - if (collection[i].Equals(value)) - return i; - return -1; - } - - private string EditorGUILayoutPopup(string label, string selected, string[] displayOption) - { - try - { - var index = EditorGUILayout.Popup(label, FindIndex(displayOption, selected), displayOption); - return displayOption[index >= 0 ? index : 0]; - } - catch (Exception e) - { - Debug.LogError(e); - } - - return string.Empty; - } -} \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture/TextureFormatSettingInspector.cs.meta b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture/TextureFormatSettingInspector.cs.meta deleted file mode 100644 index b3eb396..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture/TextureFormatSettingInspector.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e5fd574fa651d45b69d4187aa0a520da -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture/TextureFormatSettings.cs b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture/TextureFormatSettings.cs deleted file mode 100644 index d8832cf..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture/TextureFormatSettings.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System; -using System.Collections.Generic; -using UnityEditor; -using UnityEngine; -using UnityEngine.Serialization; - -[Serializable] -[CreateAssetMenu(fileName = "TextureFormatSettings", menuName = "ResourceImportSettings/TextureFormatSettings", - order = 0)] -public class TextureFormatSettings : ScriptableObject -{ - private static bool _isDirtyLock = true; - public List settings; - - public static bool IsDirtyLock - { - set => _isDirtyLock = value; - get - { - var r = _isDirtyLock; - _isDirtyLock = false; - return r; - } - } -} - -[Serializable] -public class TextureFormatSetting -{ - public string Name; - public string PreFix; - public string PostFix; - public string EndDress; - - public TextureImporterType ImporterType; - public TextureImporterShape ImporterShape = TextureImporterShape.Texture2D; - public bool GeneratePhysicShape; - public int MaxSize; - public int StandaloneMaxSize; - public bool MipMap; - public bool ForceAlphaSetting = true; - public TextureImporterAlphaSource Alpha; - public TextureWrapMode WrapMode; - - public bool IsReadable; - - public FilterMode FilterMode = FilterMode.Bilinear; - public TextureImporterNPOTScale NPOT = TextureImporterNPOTScale.ToNearest; - - public TextureImporterFormat FormatIos = TextureImporterFormat.ASTC_5x5; - public TextureImporterFormat FormatAndroid = TextureImporterFormat.ASTC_5x5; - public TextureImporterFormat FormatIosAlpha = TextureImporterFormat.ASTC_5x5; - public TextureImporterFormat FormatAndroidAlpha = TextureImporterFormat.ASTC_5x5; - public TextureImporterFormat FormatStandalone = TextureImporterFormat.RGB24; - public TextureImporterFormat FormatStandaloneAlpha = TextureImporterFormat.RGBA32; - - - public bool InspectorFoldOut; - - - public TextureImporterFormat GetFormatIos(bool hasAlpha) - { - return hasAlpha ? FormatIosAlpha : FormatIos; - } - - public TextureImporterFormat GetFormatAndroid(bool hasAlpha) - { - return hasAlpha ? FormatAndroidAlpha : FormatAndroid; - } - - public TextureImporterFormat GetFormatStandalone(bool hasAlpha) - { - return hasAlpha ? FormatStandaloneAlpha : FormatStandalone; - } -} \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture/TextureFormatSettings.cs.meta b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture/TextureFormatSettings.cs.meta deleted file mode 100644 index b63dd57..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture/TextureFormatSettings.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 241fd960f87d34d42b47d6058bfdb0e6 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture/TextureProcessor.CheckName.cs b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture/TextureProcessor.CheckName.cs deleted file mode 100644 index 8253b31..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture/TextureProcessor.CheckName.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.IO; - -public partial class TextureProcessor -{ - private string CheckName(string fileName) - { - if (fileName.Contains("ReflectionProbe-")) - { - var index = fileName.LastIndexOf("-"); - fileName = fileName.Remove(index, fileName.Length - index); - fileName += "_"; - } - - return fileName; - } - - private string GetFileName(string assetPath) - { - return Path.GetFileNameWithoutExtension(assetPath); - } -} \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture/TextureProcessor.CheckName.cs.meta b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture/TextureProcessor.CheckName.cs.meta deleted file mode 100644 index c2db475..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture/TextureProcessor.CheckName.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 090220ad1333849d1ad579d5b2701559 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture/TextureProcessor.cs b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture/TextureProcessor.cs deleted file mode 100644 index 79d7e02..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture/TextureProcessor.cs +++ /dev/null @@ -1,192 +0,0 @@ -using UnityEditor; -using UnityEngine; - -public partial class TextureProcessor : AssetPostprocessor -{ - private static TextureFormatSettings config; - - private void OnPreprocessTexture() - { - UpdateTextureFormatSettings(); - - if (config == null) return; - - var textureImporter = assetImporter as TextureImporter; - var fileName = GetFileName(textureImporter.assetPath); - - if (fileName.EndsWith(TextureFormatSettingConst.ExcludePostFix)) return; - - fileName = CheckName(fileName); - - var settings = config.settings.Find(set => ( - set.PreFix != TextureFormatSettingConst.NameFormatNone - && fileName.StartsWith(set.PreFix)) - || - (set.PostFix != TextureFormatSettingConst.NameFormatNone - && fileName.EndsWith(set.PostFix))); - - - var handleSize = true; - var handleType = true; - var handleShape = true; - var handlePhysicsShape = true; - var handleAlpha = true; - var handleFormat = true; - - if (settings == null) - { - handleSize = false; - handleType = false; - handleShape = false; - handlePhysicsShape = false; - handleAlpha = false; - handleFormat = false; - return; - } - - //size - var maxSize = settings.MaxSize; - - //Type - if (handleType) textureImporter.textureType = settings.ImporterType; - - //Shape - if (handleShape) textureImporter.textureShape = settings.ImporterShape; - - //Physics Shape - if (handlePhysicsShape) - { - var importerSettings = new TextureImporterSettings(); - textureImporter.ReadTextureSettings(importerSettings); - importerSettings.spriteGenerateFallbackPhysicsShape = settings.GeneratePhysicShape; - textureImporter.SetTextureSettings(importerSettings); - } - - - //Alpha - if (handleAlpha) - { - if (settings.ForceAlphaSetting) - { - textureImporter.alphaSource = settings.Alpha; - } - else - { - if (textureImporter.DoesSourceTextureHaveAlpha()) - { - textureImporter.alphaSource = TextureImporterAlphaSource.FromInput; - textureImporter.alphaIsTransparency = true; - } - else - { - textureImporter.alphaSource = TextureImporterAlphaSource.None; - } - } - } - - - //Format & MaxSize - var psAndroid = textureImporter.GetPlatformTextureSettings("Android"); - var psIPhone = textureImporter.GetPlatformTextureSettings("iPhone"); - var psStandalone = textureImporter.GetPlatformTextureSettings("Standalone"); - psAndroid.overridden = true; - psIPhone.overridden = true; - psStandalone.overridden = true; - - if (handleSize) - { - psIPhone.maxTextureSize = maxSize; - psAndroid.maxTextureSize = maxSize; - psStandalone.maxTextureSize = settings.StandaloneMaxSize; - } - - if (handleFormat) - { - var hasAlpha = textureImporter.DoesSourceTextureHaveAlpha(); - psAndroid.format = settings.GetFormatAndroid(hasAlpha); - psIPhone.format = settings.GetFormatIos(hasAlpha); - psStandalone.format = settings.GetFormatStandalone(hasAlpha); - } - - textureImporter.SetPlatformTextureSettings(psAndroid); - textureImporter.SetPlatformTextureSettings(psIPhone); - textureImporter.SetPlatformTextureSettings(psStandalone); - - - // //设置Read/Write Enabled开关,不勾选 - // textureImporter.isReadable = false; - - //mipmap - textureImporter.mipmapEnabled = settings.MipMap; - - textureImporter.wrapMode = settings.WrapMode; - - textureImporter.isReadable = settings.IsReadable; - - textureImporter.filterMode = settings.FilterMode; - - textureImporter.npotScale = settings.NPOT; - - void UpdateTextureFormatSettings() - { - if (config == null || TextureFormatSettings.IsDirtyLock) - { - config = - AssetDatabase.LoadAssetAtPath(TextureFormatSettingConst - .TextureFormatSettingsPath); - if (config == null) Debug.LogError("Texture format config is null"); - } - } - } - - // private TextureImporterFormat GetFormat(string platForm, bool hasAlpha) - // { - // if (platForm == "iPhone") - // { - // var format = TextureImporterFormat.ASTC_RGB_4x4; - // if (hasAlpha) format = TextureImporterFormat.ASTC_RGBA_4x4; - - // return format; - // } - - // if (platForm == "Android") - // { - // var format = TextureImporterFormat.ETC2_RGB4; - // if (hasAlpha) format = TextureImporterFormat.ETC2_RGBA8; - - // return format; - // } - - // return TextureImporterFormat.RGBA32; - // } - - - // [MenuItem("校验工具/Session01")] - // static public void AutoValidate() { - // //写入csv日志 - // StreamWriter sw = new StreamWriter("ValidateS01.csv", false, System.Text.Encoding.UTF8); - // sw.WriteLine("Validate -- Session01"); - - // string[] allAssets = AssetDatabase.GetAllAssetPaths(); - // foreach (string s in allAssets) { - // if (s.StartsWith("Assets/")) { - // Texture tex = AssetDatabase.LoadAssetAtPath(s, typeof(Texture)) as Texture; - - // if (tex) { - // //检测纹理资源命名是否合法 - // if (!Regex.IsMatch(s, @"^[a-zA-Z][a-zA-Z0-9_/.]*$")) { - // sw.WriteLine(string.Format("illegal texture filename,{0}", s)); - // } - - // //判断纹理尺寸是否符合四的倍数 - // if (((tex.width % 4) != 0) || ((tex.height % 4) != 0)) { - // sw.WriteLine(string.Format("illegal texture W/H size,{0},{1},{2}", s, tex.width, tex.height)); - // } - // } - // } - // } - - // sw.Flush(); - // sw.Close(); - // } -} \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture/TextureProcessor.cs.meta b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture/TextureProcessor.cs.meta deleted file mode 100644 index 438d3bd..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Texture/TextureProcessor.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 79db869ee1fd842c399871dfa471726a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video.meta b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video.meta deleted file mode 100644 index 781628d..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: b08651cbbe20cef42a533ea68ddc5c7c -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video/VideoFormatSetting.Const.cs b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video/VideoFormatSetting.Const.cs deleted file mode 100644 index c1c0914..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video/VideoFormatSetting.Const.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public static class VideoFormatSettingConst -{ - /// - /// 视频格式设置路径 - /// - public const string VideoFormatSettingsPath = "Assets/Editor/Settings/VideoFormatSettings.asset"; - /// - /// 忽略后缀 - /// - public static string ExcludePostFix = "_CC"; - public static string NameFormatNone = "-"; - - /// - /// 前缀 - /// - public static readonly string[] NameFormatPre = - { - NameFormatNone, // none, dont move - - "Raffle_", // 抽卡 - }; - - /// - /// 后缀 - /// - public static readonly string[] NameFormatPost = - { - NameFormatNone, // none, dont move - }; - - /// - /// 文件类型 - /// - public static readonly string[] EndDress = -{ - NameFormatNone, - - ".mp4", - }; -} diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video/VideoFormatSetting.Const.cs.meta b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video/VideoFormatSetting.Const.cs.meta deleted file mode 100644 index 28f3e3a..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video/VideoFormatSetting.Const.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b90a2566d59018e4abed2a25f2ea56a2 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video/VideoFormatSettingInspector.cs b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video/VideoFormatSettingInspector.cs deleted file mode 100644 index 7574cb1..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video/VideoFormatSettingInspector.cs +++ /dev/null @@ -1,138 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEditor; -using UnityEngine; - -[CustomEditor(typeof(VideoFormatSettings))] -public class VideoFormatSettingInspector : Editor -{ - private VideoFormatSettings targetSettings; - - public void OnEnable() - { - targetSettings = target as VideoFormatSettings; - } - - public override void OnInspectorGUI() - { - EditorGUILayout.LabelField("排除后缀为", VideoFormatSettingConst.ExcludePostFix); - - for (var i = 0; i < targetSettings.ListSetting.Count; i++) - { - VideoFormatSetting setting = targetSettings.ListSetting[i]; - using (new EditorGUILayout.HorizontalScope()) - { - setting.Name = EditorGUILayout.TextField("种类", setting.Name); - if (GUILayout.Button("↑") && i > 0) - { - targetSettings.ListSetting[i] = targetSettings.ListSetting[i - 1]; - targetSettings.ListSetting[i - 1] = setting; - } - - if (GUILayout.Button("↓") && i < targetSettings.ListSetting.Count - 1) - { - targetSettings.ListSetting[i] = targetSettings.ListSetting[i + 1]; - targetSettings.ListSetting[i + 1] = setting; - } - - if (GUILayout.Button("删")) - { - for (int j = i + 1; j < targetSettings.ListSetting.Count; ++j) - { - targetSettings.ListSetting[j - 1] = targetSettings.ListSetting[j]; - } - - targetSettings.ListSetting.RemoveAt(targetSettings.ListSetting.Count - 1); - - if (i < targetSettings.ListSetting.Count) - setting = targetSettings.ListSetting[i]; - } - } - - setting.IsInspectorFoldOut = EditorGUILayout.Foldout(setting.IsInspectorFoldOut, ""); - if (setting.IsInspectorFoldOut) - { - setting.PreFix = EditorGUILayoutPopup("前缀", setting.PreFix, VideoFormatSettingConst.NameFormatPre); - setting.PostFix = EditorGUILayoutPopup("后缀", setting.PostFix, VideoFormatSettingConst.NameFormatPost); - setting.EndDress = EditorGUILayoutPopup("文件类型", setting.EndDress, VideoFormatSettingConst.EndDress); - - setting.EnableTranscoding = EditorGUILayout.Toggle("EnableTranscoding", setting.EnableTranscoding); - setting.ResizeMode = (VideoResizeMode)EditorGUILayout.EnumPopup("ResizeMode", setting.ResizeMode); - setting.AspectRatio = (VideoEncodeAspectRatio)EditorGUILayout.EnumPopup("AspectRatio", setting.AspectRatio); - setting.Codec = (VideoCodec)EditorGUILayout.EnumPopup("Codec", setting.Codec); - setting.BitrateMode = (VideoBitrateMode)EditorGUILayout.EnumPopup("BitrateMode", setting.BitrateMode); - setting.SpatialQuality = (VideoSpatialQuality)EditorGUILayout.EnumPopup("SpatialQuality", setting.SpatialQuality); - setting.DeinterlaceMode = (VideoDeinterlaceMode)EditorGUILayout.EnumPopup("DeinterlaceMode", setting.DeinterlaceMode); - setting.FlipHorizontal = EditorGUILayout.Toggle("FlipHorizontal", setting.FlipHorizontal); - setting.FlipVertical = EditorGUILayout.Toggle("FlipVertical", setting.FlipVertical); - setting.ImportAudio = EditorGUILayout.Toggle("ImportAudio", setting.ImportAudio); - } - - EditorGUILayout.Separator(); - EditorGUILayout.Separator(); - EditorGUILayout.Separator(); - EditorGUILayout.Separator(); - } - - if (GUILayout.Button("+")) - targetSettings.ListSetting.Add(new VideoFormatSetting { Name = "未知" }); - - TextureFormatSettings.IsDirtyLock = true; - EditorUtility.SetDirty(targetSettings); - - using (new EditorGUILayout.HorizontalScope()) - { - if (GUILayout.Button("Save")) - { - } - - if (GUILayout.Button("ReImport All Video")) - { - } - } - } - - /// - /// 查找索引 - /// - /// - /// - /// - /// - private int FindIndex(IReadOnlyList collection, T value) - { - if (null == collection) - return -1; - - for (int i = 0; i < collection.Count; ++i) - { - if (collection[i].Equals(value)) - return i; - } - - return -1; - } - - /// - /// 弹出框 - /// - /// - /// - /// - /// - private string EditorGUILayoutPopup(string label, string selected, string[] displayOption) - { - try - { - int index = EditorGUILayout.Popup(label, FindIndex(displayOption, selected), displayOption); - return displayOption[index >= 0 ? index : 0]; - } - catch (Exception e) - { - Debug.LogError(e); - } - - return string.Empty; - } -} \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video/VideoFormatSettingInspector.cs.meta b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video/VideoFormatSettingInspector.cs.meta deleted file mode 100644 index cd14e59..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video/VideoFormatSettingInspector.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 16497f7524ba1424e87ce23bba4d4398 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video/VideoFormatSettings.cs b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video/VideoFormatSettings.cs deleted file mode 100644 index 43da151..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video/VideoFormatSettings.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEditor; -using UnityEngine; -using UnityEngine.Video; - -/// -/// 视频格式设置 -/// -[Serializable] -[CreateAssetMenu(fileName = "VideoFormatSettings", menuName = "ResourceImportSettings/VideoFormatSettings", order = 0)] -public class VideoFormatSettings : ScriptableObject -{ - private static bool isDirtyLock = true; - public List ListSetting; - - public static bool IsDirtyLock - { - get - { - bool r = isDirtyLock; - isDirtyLock = false; - - return r; - } - set { isDirtyLock = value; } - } -} - -[Serializable] -public class VideoFormatSetting -{ - public string Name; - /// - /// 前缀 - /// - public string PreFix; - /// - /// 后缀 - /// - public string PostFix; - /// - /// 文件类型 - /// - public string EndDress; - - public bool EnableTranscoding = true; - public VideoResizeMode ResizeMode = VideoResizeMode.HalfRes; - public VideoEncodeAspectRatio AspectRatio = VideoEncodeAspectRatio.Stretch; - public VideoCodec Codec = VideoCodec.VP8; - public VideoBitrateMode BitrateMode = VideoBitrateMode.High; - public VideoSpatialQuality SpatialQuality = VideoSpatialQuality.HighSpatialQuality; - - public VideoDeinterlaceMode DeinterlaceMode = VideoDeinterlaceMode.Off; - public bool FlipHorizontal = false; - public bool FlipVertical = false; - public bool ImportAudio = true; - - public bool IsInspectorFoldOut; - -} \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video/VideoFormatSettings.cs.meta b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video/VideoFormatSettings.cs.meta deleted file mode 100644 index 95ad5d9..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video/VideoFormatSettings.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6f2876953098c9f468aa6cad3c6df275 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video/VideoProcessor.CheckName.cs b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video/VideoProcessor.CheckName.cs deleted file mode 100644 index 885f805..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video/VideoProcessor.CheckName.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.IO; - -public partial class VideoProcessor -{ - private string CheckName(string fileName) - { - if (fileName.Contains("ReflectionProbe-")) - { - int index = fileName.LastIndexOf("-"); - fileName = fileName.Remove(index, fileName.Length - index); - fileName += "_"; - } - - return fileName; - } - - private string GetFileName(string assetPath) - { - return Path.GetFileNameWithoutExtension(assetPath); - } -} diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video/VideoProcessor.CheckName.cs.meta b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video/VideoProcessor.CheckName.cs.meta deleted file mode 100644 index f5502df..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video/VideoProcessor.CheckName.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0f81d25e10192b8478e006c0f5729ffd -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video/VideoProcessor.cs b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video/VideoProcessor.cs deleted file mode 100644 index b06e45a..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video/VideoProcessor.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using System.IO; -using UnityEditor; -using UnityEngine; - -public partial class VideoProcessor : AssetPostprocessor -{ - private static VideoFormatSettings config; - - private void OnPreprocessAsset() - { - string endDress = Path.GetExtension(assetPath).ToLower(); - if (!endDress.Equals(".mp4") && - !endDress.Equals(".mov") && - !endDress.Equals(".avi")) - { - return; - } - - UpdateVideoFormatSettings(); - if (config == null) - return; - - // 设置导入设置 - VideoClipImporter videoImporter = assetImporter as VideoClipImporter; - if (null == videoImporter) - return; - - string fileName = GetFileName(videoImporter.assetPath); - - if (fileName.EndsWith(VideoFormatSettingConst.ExcludePostFix)) - return; - - fileName = CheckName(fileName); - - VideoFormatSetting settings = config.ListSetting.Find(set => - ( - set.PreFix != TextureFormatSettingConst.NameFormatNone && fileName.StartsWith(set.PreFix)) || - (set.PostFix != TextureFormatSettingConst.NameFormatNone && fileName.EndsWith(set.PostFix)) - ); - - #region 设置视频的导入格式和输出分辨率 - VideoImporterTargetSettings androidSetting = videoImporter.GetTargetSettings("Android"); - VideoImporterTargetSettings iosSetting = videoImporter.GetTargetSettings("iPhone"); - if (androidSetting != null && iosSetting != null) // 已经设置过的不重复设置 - { - if (androidSetting.enableTranscoding == settings.EnableTranscoding && iosSetting.enableTranscoding == settings.EnableTranscoding && - androidSetting.resizeMode == settings.ResizeMode && iosSetting.resizeMode == settings.ResizeMode && - androidSetting.aspectRatio == settings.AspectRatio && iosSetting.aspectRatio == settings.AspectRatio && - androidSetting.codec == settings.Codec && iosSetting.codec == settings.Codec && - androidSetting.bitrateMode == settings.BitrateMode && iosSetting.bitrateMode == settings.BitrateMode && - androidSetting.spatialQuality == settings.SpatialQuality && iosSetting.spatialQuality == settings.SpatialQuality) - { - return; - } - } - - VideoImporterTargetSettings targetSettings = new() - { - enableTranscoding = settings.EnableTranscoding, - resizeMode = settings.ResizeMode, - aspectRatio = settings.AspectRatio, - codec = settings.Codec, - bitrateMode = settings.BitrateMode, - spatialQuality = settings.SpatialQuality, - - }; - - videoImporter.SetTargetSettings("Android", targetSettings); - videoImporter.SetTargetSettings("iPhone", targetSettings); - videoImporter.deinterlaceMode = settings.DeinterlaceMode; - videoImporter.flipHorizontal = settings.FlipHorizontal; - videoImporter.flipVertical = settings.FlipVertical; - videoImporter.importAudio = settings.ImportAudio; - #endregion - } - - private void UpdateVideoFormatSettings() - { - if (config == null || VideoFormatSettings.IsDirtyLock) - { - config = AssetDatabase.LoadAssetAtPath(VideoFormatSettingConst.VideoFormatSettingsPath); - if (config == null) - Debug.LogError("Video format config is null"); - } - } -} \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video/VideoProcessor.cs.meta b/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video/VideoProcessor.cs.meta deleted file mode 100644 index 7eaa7b0..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AssetPostProcessor/Video/VideoProcessor.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: bb0a4d7e78dc7a043ae55b1932265e99 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/AutoCombine.meta b/Forest/Assets/PhxhSDK/Editor/AutoCombine.meta deleted file mode 100644 index 8b50722..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AutoCombine.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 2cc6cd0fb49146789026812735f60505 -timeCreated: 1704259084 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/AutoCombine/AutoCombine.cs b/Forest/Assets/PhxhSDK/Editor/AutoCombine/AutoCombine.cs deleted file mode 100644 index b4a6c44..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AutoCombine/AutoCombine.cs +++ /dev/null @@ -1,237 +0,0 @@ -using System.Collections.Generic; -using UnityEngine; -namespace PhxhSDK.Phxh.AutoCombine -{ - public class AutoCombine - { - - public static void ConvertMeshToSkinMesh(GameObject obj) - { - var allMeshRenders = obj.GetComponentsInChildren(true); - foreach (var meshRender in allMeshRenders) - { - var meshFilter = meshRender.GetComponent(); - if (meshFilter == null) continue; - var mesh = meshFilter.sharedMesh; - if (mesh == null) continue; - var skinMesh = new GameObject(mesh.name); - skinMesh.transform.SetParent(obj.transform); - - var skinMeshRender = skinMesh.AddComponent(); - skinMeshRender.sharedMesh = mesh; - skinMeshRender.sharedMaterial = meshRender.sharedMaterial; - - // 设置骨骼 - var rootBone = meshRender.transform.parent; - skinMeshRender.rootBone = rootBone; - skinMeshRender.bones = new[] {rootBone}; - - // 设置bindposes - var bindPose = rootBone.worldToLocalMatrix * meshRender.transform.localToWorldMatrix; - skinMeshRender.sharedMesh.bindposes = new[] {bindPose}; - - // 设置权重 - var vertexCount = mesh.vertexCount; - var boneWeights = new BoneWeight[vertexCount]; - for (int i = 0; i < vertexCount; i++) - { - boneWeights[i].boneIndex0 = 0; - boneWeights[i].weight0 = 1; - } - skinMeshRender.sharedMesh.boneWeights = boneWeights; - - Object.DestroyImmediate(meshRender.gameObject); - } - } - - public static void CombineSkinMesh(GameObject obj,string[] textureNames,int combineTexSize = 2048) - { - Dictionary> needCombinelist = new Dictionary>(); - SkinnedMeshRenderer[] parts = obj.GetComponentsInChildren(true); - foreach (var item in parts) - { - var shaderName = item.sharedMaterial.shader.name; - if (needCombinelist.ContainsKey(shaderName)) - { - needCombinelist[shaderName].Add(item); - } - else - { - var addList = new List(); - addList.Add(item); - needCombinelist.Add(shaderName, addList); - } - } - - foreach (var item in needCombinelist) - { - // 只有一个不合并 - if (item.Value.Count <= 1) continue; - List bones = new List(); - List uvList = new List(); - List combineInstances = new List(); - Material mat = Object.Instantiate(item.Value[0].sharedMaterial) as Material; - Dictionary> textureDict = new Dictionary>(); - int uvCount = 0; - foreach (var cur in item.Value) - { - CombineInstance ci = new CombineInstance(); - ci.mesh = DeepCopyMesh(cur.sharedMesh); - // ci.transform = cur.transform.localToWorldMatrix; - combineInstances.Add(ci); - uvList.Add(cur.sharedMesh.uv); - uvCount += cur.sharedMesh.uv.Length; - foreach (var needCombineTex in textureNames) - { - var getTexture = cur.sharedMaterial.GetTexture(needCombineTex) as Texture2D; - if (textureDict.ContainsKey(needCombineTex)) - { - textureDict[needCombineTex].Add(getTexture); - } - else - { - List addList = new List(); - addList.Add(getTexture); - textureDict.Add(needCombineTex, addList); - } - } - for (int k = 0; k < cur.bones.Length; k++) - { - bones.Add(cur.bones[k]); - } - } - - Dictionary combinedTexs = new Dictionary(); - Rect[] packingResult = null; - foreach (var needPackTexList in textureDict) - { - Texture2D newCombineTex = new Texture2D(4, 4, TextureFormat.ARGB4444, true); - if (packingResult == null) - { - packingResult = newCombineTex.PackTextures(needPackTexList.Value.ToArray(), 0, combineTexSize); - } - else - { - newCombineTex.PackTextures(needPackTexList.Value.ToArray(), 0, combineTexSize); - } - combinedTexs.Add(needPackTexList.Key, newCombineTex); - } - - //string textureName = "autocombine" + obj.name; - Vector2[] atlasUVs = new Vector2[uvCount]; - int count = 0; - for (int i = 0; i < uvList.Count; i++) - { - var tmpArray = uvList[i]; - for (int j = 0; j < tmpArray.Length; j++) - { - Vector2 uv = tmpArray[j]; - atlasUVs[count].x = Mathf.Lerp(packingResult[i].xMin, packingResult[i].xMax, uv.x); - atlasUVs[count].y = Mathf.Lerp(packingResult[i].yMin, packingResult[i].yMax, uv.y); - count++; - } - } - GameObject newSkinnedGo = new GameObject("CombineObj_" + _ConvertShaderName(item.Key)); - newSkinnedGo.transform.SetParent(obj.transform); - - var s = newSkinnedGo.AddComponent(); - Mesh nMesh = new Mesh(); - nMesh.CombineMeshes(combineInstances.ToArray(), true, false); - s.sharedMesh = nMesh; - // s.sharedMesh = CombineMeshesWithTransformsAndBones(combineInstances.ToArray()); - s.bones = bones.ToArray(); - s.sharedMesh.uv = atlasUVs; - s.sharedMaterial = mat; - - foreach (var combineTex in combinedTexs) - { - s.sharedMaterial.SetTexture(combineTex.Key, combineTex.Value); - } - - for (int i = 0; i < item.Value.Count; i++) - { - var skin = item.Value[i]; - Object.DestroyImmediate(skin.gameObject, true); - } - } - } - - public static Mesh DeepCopyMesh(Mesh originalMesh) - { - Mesh copiedMesh = new Mesh(); - - copiedMesh.vertices = (Vector3[])originalMesh.vertices.Clone(); - copiedMesh.triangles = (int[])originalMesh.triangles.Clone(); - copiedMesh.uv = (Vector2[])originalMesh.uv.Clone(); - copiedMesh.normals = (Vector3[])originalMesh.normals.Clone(); - copiedMesh.tangents = (Vector4[])originalMesh.tangents.Clone(); - copiedMesh.colors = (Color[])originalMesh.colors.Clone(); - copiedMesh.boneWeights = (BoneWeight[])originalMesh.boneWeights.Clone(); - copiedMesh.bindposes = (Matrix4x4[])originalMesh.bindposes.Clone(); - - return copiedMesh; - } - - public static Mesh CombineMeshesWithTransformsAndBones(CombineInstance[] combineInstances) - { - List vertices = new List(); - List triangles = new List(); - List uvs = new List(); - List boneWeights = new List(); - List bindposes = new List(); - - for (int i = 0; i < combineInstances.Length; i++) - { - Mesh mesh = combineInstances[i].mesh; - Matrix4x4 transform = combineInstances[i].transform; - - if (mesh == null) - { - Debug.LogError("没有mesh"); - continue; - } - - for (var j = 0; j < mesh.vertices.Length; ++j) - { - var vertex = mesh.vertices[j]; - var bipPos = mesh.bindposes[j]; - - vertices.Add(bipPos.MultiplyPoint3x4(vertex)); - } - - foreach (Vector2 uv in mesh.uv) - { - uvs.Add(uv); - } - - int vertexOffset = vertices.Count - mesh.vertexCount; - foreach (int triangle in mesh.triangles) - { - triangles.Add(vertexOffset + triangle); - } - - // 添加骨骼权重和绑定姿势 - boneWeights.AddRange(mesh.boneWeights); - bindposes.AddRange(mesh.bindposes); - } - - Mesh combinedMesh = new Mesh(); - combinedMesh.vertices = vertices.ToArray(); - combinedMesh.triangles = triangles.ToArray(); - combinedMesh.uv = uvs.ToArray(); - combinedMesh.boneWeights = boneWeights.ToArray(); - combinedMesh.bindposes = bindposes.ToArray(); - - return combinedMesh; - } - - private static string _ConvertShaderName(string shaderName) - { - // 将/替换为_ - shaderName = shaderName.Replace("/", "_"); - // 将空格替换为_ - shaderName = shaderName.Replace(" ", "_"); - return shaderName; - } - } -} diff --git a/Forest/Assets/PhxhSDK/Editor/AutoCombine/AutoCombine.cs.meta b/Forest/Assets/PhxhSDK/Editor/AutoCombine/AutoCombine.cs.meta deleted file mode 100644 index 7a17259..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AutoCombine/AutoCombine.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 51b50b155c5c4401ba71a7b347e322e4 -timeCreated: 1704259092 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/AutoCombine/Inspector.meta b/Forest/Assets/PhxhSDK/Editor/AutoCombine/Inspector.meta deleted file mode 100644 index 95d4c41..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AutoCombine/Inspector.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: ea835a762fa042a883b89cafbaf5929a -timeCreated: 1716894113 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/AutoCombine/Inspector/CmpSkinCombineInspector.cs b/Forest/Assets/PhxhSDK/Editor/AutoCombine/Inspector/CmpSkinCombineInspector.cs deleted file mode 100644 index d0bfe58..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AutoCombine/Inspector/CmpSkinCombineInspector.cs +++ /dev/null @@ -1,27 +0,0 @@ -using PhxhSDK.Phxh.Others; -using UnityEditor; -using UnityEngine; - -namespace PhxhSDK.Phxh.AutoCombine.Inspector -{ - [CustomEditor(typeof(CmpSkinCombine))] - public class CmpSkinCombineInspector : UnityEditor.Editor - { - - public override void OnInspectorGUI() - { - // base.OnInspectorGUI(); - var cmp = target as CmpSkinCombine; - if (cmp == null) return; - if (GUILayout.Button("转换所有Mesh为SkinMesh", GUILayout.Height(40))) - { - AutoCombine.ConvertMeshToSkinMesh(cmp.gameObject); - } - if (GUILayout.Button("合并所有SkinMesh", GUILayout.Height(40))) - { - AutoCombine.CombineSkinMesh(cmp.gameObject, new string[] { "_MainTex", "_MaskTex" }); - } - } - - } -} diff --git a/Forest/Assets/PhxhSDK/Editor/AutoCombine/Inspector/CmpSkinCombineInspector.cs.meta b/Forest/Assets/PhxhSDK/Editor/AutoCombine/Inspector/CmpSkinCombineInspector.cs.meta deleted file mode 100644 index 0a9d608..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AutoCombine/Inspector/CmpSkinCombineInspector.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: d4cd9c040ace42bfa152950483bb1c0d -timeCreated: 1716894123 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/AutoCombine/Performance.meta b/Forest/Assets/PhxhSDK/Editor/AutoCombine/Performance.meta deleted file mode 100644 index 6e55bd9..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AutoCombine/Performance.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 17313f90a5414192b618e320758a754a -timeCreated: 1703670894 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/AutoCombine/Performance/Data.meta b/Forest/Assets/PhxhSDK/Editor/AutoCombine/Performance/Data.meta deleted file mode 100644 index f7aebc5..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AutoCombine/Performance/Data.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 7c21427ed9e049f49be82588f2c2ef72 -timeCreated: 1703671650 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/AutoCombine/Performance/Data/AutoCombieMeshData.cs b/Forest/Assets/PhxhSDK/Editor/AutoCombine/Performance/Data/AutoCombieMeshData.cs deleted file mode 100644 index 46e95d2..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AutoCombine/Performance/Data/AutoCombieMeshData.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Collections.Generic; -using UnityEngine; - -namespace Performance.Data -{ - public class AutoCombieMeshData - { - - public Mesh mesh; - public List objs = new List(); - - public AutoCombieMeshData(Mesh mesh) - { - this.mesh = mesh; - } - - public void AddObj(GameObject obj) - { - objs.Add(obj); - } - - } -} diff --git a/Forest/Assets/PhxhSDK/Editor/AutoCombine/Performance/Data/AutoCombieMeshData.cs.meta b/Forest/Assets/PhxhSDK/Editor/AutoCombine/Performance/Data/AutoCombieMeshData.cs.meta deleted file mode 100644 index 763f08b..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AutoCombine/Performance/Data/AutoCombieMeshData.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 11d7a1f0d53d4c45b0e32129671d2242 -timeCreated: 1703671666 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/AutoCombine/Performance/Data/AutoCombieShaderData.cs b/Forest/Assets/PhxhSDK/Editor/AutoCombine/Performance/Data/AutoCombieShaderData.cs deleted file mode 100644 index 474e96c..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AutoCombine/Performance/Data/AutoCombieShaderData.cs +++ /dev/null @@ -1,270 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using UnityEditor; -using UnityEngine; -using UnityEngine.SceneManagement; -namespace Performance.Data -{ - public class AutoCombieShaderData - { - public Shader shader; - public List renderers = new List(); - private int _textureXCount; - - public Vector2Int calcSize; - private int _unitSize; - - - public AutoCombieShaderData(Shader shader, - int forceUnitSize = 256) - { - this.shader = shader; - _unitSize = forceUnitSize; - } - - public void AddRenderer(Renderer renderer) - { - renderers.Add(renderer); - } - - public void PreCalc() - { - var mainTexName = "_MainTex"; - var maskTexName = "_MaskTex"; - - var totalMats = new List(); - for (int i = 0; i < renderers.Count; i++) - { - var renderer = renderers[i]; - var shareMaterial = renderer.sharedMaterial; - if (totalMats.Contains(shareMaterial)) - { - continue; - } - totalMats.Add(shareMaterial); - } - - var totalMainTexs = new List(); - for (int i = 0; i < totalMats.Count; i++) - { - var mat = totalMats[i]; - var mainTex = mat.GetTexture(mainTexName) as Texture2D; - if (mainTex == null) - { - Debug.LogError($"材质{mat.name}没有主贴图: {mainTexName}", mat); - continue; - } - var maskTex = mat.GetTexture(maskTexName) as Texture2D; - if (maskTex == null) - { - Debug.LogError($"材质{mat.name}没有遮罩贴图: {maskTexName}", mat); - continue; - } - if (!totalMainTexs.Contains(mainTex)) - { - totalMainTexs.Add(mainTex); - } - } - calcSize = _CalcTexSize(totalMainTexs); - } - - public GameObject CombieToOneObj(string outputPath) - { - switch (shader.name) - { - case "NLD_URP/NLD_Charactor_Lambert": - case "NLD_URP/NLD_Charactor": - case "NLD_URP/NLD_Scene_Lambert": - case "NLD_URP/NLD_Scene_Lambert_DoubleSide": - return _HandleForNLD(outputPath); - default: - DebugUtil.LogError("未处理的Shader: " + shader.name); - break; - } - return null; - } - - private GameObject _HandleForNLD(string outPutDir) - { - var mainTexName = "_MainTex"; - var maskTexName = "_MaskTex"; - var firstMaterial = renderers[0].sharedMaterial; - - var totalMats = new List(); - for (int i = 0; i < renderers.Count; i++) - { - var renderer = renderers[i]; - var shareMaterial = renderer.sharedMaterial; - if (totalMats.Contains(shareMaterial)) - { - continue; - } - totalMats.Add(shareMaterial); - } - - var totalMainTexs = new List(); - var totalMaskTexs = new List(); - for (int i = 0; i < totalMats.Count; i++) - { - var mat = totalMats[i]; - var mainTex = mat.GetTexture(mainTexName) as Texture2D; - if (mainTex == null) - { - Debug.LogError($"材质{mat.name}没有主贴图: {mainTexName}", mat); - continue; - } - var maskTex = mat.GetTexture(maskTexName) as Texture2D; - if (maskTex == null) - { - Debug.LogError($"材质{mat.name}没有遮罩贴图: {maskTexName}", mat); - continue; - } - if (!totalMainTexs.Contains(mainTex)) - { - totalMainTexs.Add(mainTex); - totalMaskTexs.Add(maskTex); - } - } - - var outputPath = _GetOutputPath(outPutDir); - var combieMainTex = _CombieTextures(totalMainTexs); - var combieMaskTex = _CombieTextures(totalMaskTexs); - // 保存贴图 - var mainTexPath = outputPath + "/CombieMainTex.png"; - var maskTexPath = outputPath + "/CombieMaskTex.png"; - File.WriteAllBytes(mainTexPath, combieMainTex.EncodeToPNG()); - File.WriteAllBytes(maskTexPath, combieMaskTex.EncodeToPNG()); - // 重新加载贴图 - AssetDatabase.Refresh(); - combieMainTex = AssetDatabase.LoadAssetAtPath(mainTexPath); - combieMaskTex = AssetDatabase.LoadAssetAtPath(maskTexPath); - - // 从第一个材质上clone一个 - var resultMat = new Material(firstMaterial); - resultMat.SetTexture(mainTexName, combieMainTex); - resultMat.SetTexture(maskTexName, combieMaskTex); - - var combieInsts = new List(); - var uvList = new List(); - for (int i = 0; i < renderers.Count; i++) - { - var renderer = renderers[i]; - var meshFilter = renderer.GetComponent(); - var mesh = meshFilter.sharedMesh; - var combieInst = new CombineInstance - { - mesh = mesh, - transform = renderer.transform.localToWorldMatrix - }; - var mainTex = renderer.sharedMaterial.GetTexture(mainTexName) as Texture2D; - var texIndex = totalMainTexs.IndexOf(mainTex); - var uvs = mesh.uv; - // 重新计算uv - // 把所有贴图拼接到一起 - // 从左到右,从上到下 - // 每张贴图缩放到unitSize - var xIndex = texIndex % _textureXCount; - var yIndex = texIndex / _textureXCount; - var uvScale = new Vector2(1f / _textureXCount, 1f / _textureXCount); - for (int j = 0; j < uvs.Length; j++) - { - var uv = uvs[j]; - uv.x = uv.x * uvScale.x + xIndex * uvScale.x; - uv.y = uv.y * uvScale.y + yIndex * uvScale.y; - uvList.Add(uv); - } - - combieInsts.Add(combieInst); - } - var resultMesh = new Mesh(); - resultMesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32; - resultMesh.CombineMeshes(combieInsts.ToArray(), true, true); - resultMesh.uv = uvList.ToArray(); - - var objName = _ConvertShaderName(shader.name); - var resultObj = new GameObject(objName); - var resultRenderer = resultObj.AddComponent(); - var resultFilter = resultObj.AddComponent(); - resultFilter.sharedMesh = resultMesh; - resultRenderer.sharedMaterial = resultMat; - // 保存到本地 - // 保存材质 - var matPath = outputPath + "/CombieMat.mat"; - AssetDatabase.CreateAsset(resultMat, matPath); - // 保存网格 - var meshPath = outputPath + "/CombieMesh.asset"; - AssetDatabase.CreateAsset(resultMesh, meshPath); - - return resultObj; - } - - private string _GetOutputPath(string dir) - { - // 获取当前场景所在文件夹 - // var scenePath = SceneManager.GetActiveScene().path; - // var sceneName = Path.GetFileNameWithoutExtension(scenePath); - // var sceneDir = Path.GetDirectoryName(scenePath); - var outputPath = $"{dir}/{_ConvertShaderName(shader.name)}"; - if (!Directory.Exists(outputPath)) - { - Directory.CreateDirectory(outputPath); - } - return outputPath; - } - - private string _ConvertShaderName(string shaderName) - { - var result = shaderName.Replace("/", "_"); - return result; - } - - - private Texture2D _CombieTextures(List textures) - { - var texSize = _CalcTexSize(textures); - var result = new Texture2D(texSize.x, texSize.y); - // 把所有贴图拼接到一起 - // 从左到右,从上到下 - // 每张贴图缩放到unitSize - var x = 0; - var y = 0; - for (int i = 0; i < textures.Count; i++) - { - var texture = textures[i]; - var scaleTexture = _ScaleTexture(texture); - result.SetPixels(x, y, scaleTexture.width, scaleTexture.height, scaleTexture.GetPixels()); - x += _unitSize; - if (x >= texSize.x) - { - x = 0; - y += _unitSize; - } - } - return result; - } - - private Texture2D _ScaleTexture(Texture2D texture) - { - var result = new Texture2D(_unitSize, _unitSize); - // 通过Graphics.ConvertTexture转换 - var renderTexture = new RenderTexture(_unitSize, _unitSize, 0); - Graphics.Blit(texture, renderTexture); - RenderTexture.active = renderTexture; - result.ReadPixels(new Rect(0, 0, _unitSize, _unitSize), 0, 0); - result.Apply(); - - return result; - } - - private Vector2Int _CalcTexSize(List textures) - { - // 所有贴图都是正方形 - var count = textures.Count; - var sqrt = Mathf.Sqrt(count); - var ceil = Mathf.CeilToInt(sqrt); - var result = new Vector2Int(ceil * _unitSize, ceil * _unitSize); - _textureXCount = ceil; - return result; - } - } -} diff --git a/Forest/Assets/PhxhSDK/Editor/AutoCombine/Performance/Data/AutoCombieShaderData.cs.meta b/Forest/Assets/PhxhSDK/Editor/AutoCombine/Performance/Data/AutoCombieShaderData.cs.meta deleted file mode 100644 index 8917676..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AutoCombine/Performance/Data/AutoCombieShaderData.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: fa319b38d2d6469ea141cda54fbcbde8 -timeCreated: 1703673318 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/AutoCombine/Performance/PerformanceWindow.cs b/Forest/Assets/PhxhSDK/Editor/AutoCombine/Performance/PerformanceWindow.cs deleted file mode 100644 index 4b63710..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AutoCombine/Performance/PerformanceWindow.cs +++ /dev/null @@ -1,323 +0,0 @@ -using System.Collections.Generic; -using Performance.Data; -using Tools.Shader; -using UnityEditor; -using UnityEngine; -using UnityEngine.SceneManagement; - -namespace Performance -{ - public class PerformanceWindow : EditorWindow - { - - [MenuItem("Tools/性能优化/打开窗口")] - public static void ShowWindow() - { - var window = GetWindow(); - window.titleContent = new GUIContent("性能优化"); - window.Show(); - } - - private GameObject _selectObj; - private bool _isAnalysised; - [SerializeField] - private List _skipChilds = new List() - { - "Trees", // 树 - "Stuffs", // 树 - "Ground", // 地面,走大贴图 - "Lights", // 灯光 - "Fog", // 雾,是一个特殊的材质 - "Global Volume", // 全局后处理 - }; - private List _cacheMeshes = new List(); - private List _cacheShaders = new List(); - - private Vector2 _scrollPos1; - private Vector2 _scrollPos2; - - private SerializedObject _serializedObject; - private SerializedProperty _serializedProperty; - private int _forceUnitTextureSize = 256; - - private int _totalCount; - - private GameObject _cacheRootObj; - - private void _InitFiled() - { - _serializedObject = new SerializedObject(this); - _serializedProperty = _serializedObject.FindProperty("_skipChilds"); - _cacheRootObj = GameObject.Find("CombieRoot"); - _selectObj = GameObject.Find("Art"); - } - - private void OnGUI() - { - // 自动勾选所有材质的GPU Instancing - if (GUILayout.Button("自动勾选所有材质的GPU Instancing")) - { - AutoSetAllGpuInst.AutoSet(); - } - - if (_serializedObject == null) - { - _InitFiled(); - } - _serializedObject.Update(); - EditorGUILayout.PropertyField(_serializedProperty, true); - _serializedObject.ApplyModifiedProperties(); - - var selectObj = EditorGUILayout.ObjectField("场景根节点", _selectObj, typeof(GameObject), true) as GameObject; - if (selectObj != _selectObj) - { - _selectObj = selectObj; - _cacheMeshes.Clear(); - _cacheShaders.Clear(); - _isAnalysised = false; - _totalCount = 0; - _cacheRootObj = GameObject.Find("CombieRoot"); - } - - _forceUnitTextureSize = EditorGUILayout.IntField("强制单张贴图大小", _forceUnitTextureSize); - if (GUILayout.Button("分析")) - { - _DoAnalysis(); - } - - if (_isAnalysised) - { - GUILayout.Label($"共有不同的Mesh: {_cacheMeshes.Count}个"); - GUILayout.Label($"预计合并后的顶点数量: {_totalCount}个"); - _scrollPos1 = EditorGUILayout.BeginScrollView(_scrollPos1, GUILayout.Height(100)); - GUILayout.BeginVertical(); - foreach (var mesh in _cacheMeshes) - { - GUILayout.Label($" {mesh.objs.Count}个 {mesh.mesh.name}"); - } - GUILayout.EndVertical(); - EditorGUILayout.EndScrollView(); - - GUILayout.Label($"共有不同的Shader: {_cacheShaders.Count}个"); - _scrollPos2 = EditorGUILayout.BeginScrollView(_scrollPos2, GUILayout.Height(100)); - GUILayout.BeginVertical(); - foreach (var shader in _cacheShaders) - { - GUILayout.Label($" {shader.renderers.Count}个 {shader.shader.name} 预计贴图大小: {shader.calcSize}"); - } - GUILayout.EndVertical(); - EditorGUILayout.EndScrollView(); - - if (GUILayout.Button("自动合并")) - { - _DoCombie(); - } - } - - if (_cacheRootObj != null) - { - GUILayout.BeginHorizontal(); - // 还原和切换 - if (GUILayout.Button("还原")) - { - _ShowCombie(false); - } - if (GUILayout.Button("切换")) - { - _ShowCombie(true); - } - GUILayout.EndHorizontal(); - } - } - - private void _ShowCombie(bool show) - { - if (show) - { - // 隐藏原始节点 - _SetOldObjActive(false); - // 显示合并节点 - _cacheRootObj.SetActive(true); - } - else - { - // 隐藏合并节点 - _cacheRootObj.SetActive(false); - // 显示原始节点 - _SetOldObjActive(true); - } - } - - private void _SetOldObjActive(bool active) - { - if (_selectObj == null) - { - return; - } - var childCount = _selectObj.transform.childCount; - for (var i = 0; i < childCount; ++i) - { - var child = _selectObj.transform.GetChild(i); - if (_skipChilds.Contains(child.name)) - { - continue; - } - child.gameObject.SetActive(active); - } - } - - private void _DoCombie() - { - // 强制替换 - if (_cacheRootObj == null) - { - var findObj = GameObject.Find("CombieRoot"); - if (findObj != null) - { - DestroyImmediate(findObj); - } - } - else - { - DestroyImmediate(_cacheRootObj); - } - _cacheRootObj = new GameObject("CombieRoot"); - var sceneDir = SceneManager.GetActiveScene(); - - for (int i = 0; i < _cacheShaders.Count; i++) - { - var shaderData = _cacheShaders[i]; - var combieObj = shaderData.CombieToOneObj($"{sceneDir}/Combined"); - if (combieObj == null) - { - continue; - } - combieObj.transform.SetParent(_cacheRootObj.transform); - } - - // 隐藏原始节点 - _SetOldObjActive(false); - AssetDatabase.Refresh(); - } - - private List _CollectRenderers() - { - var result = new List(); - var childCount = _selectObj.transform.childCount; - for (var i = 0; i < childCount; ++i) - { - var child = _selectObj.transform.GetChild(i); - if (_skipChilds.Contains(child.name)) - { - continue; - } - var renderers = child.GetComponentsInChildren(); - result.AddRange(renderers); - } - return result; - } - - private void _DoAnalysis() - { - if (_selectObj == null) - { - Debug.LogError("请先选择场景根节点"); - return; - } - - var renderers = _CollectRenderers(); - _CollectMeshs(renderers); - _CollectShaders(renderers); - - _isAnalysised = true; - } - - private void _CollectShaders(List renderers) - { - _cacheShaders.Clear(); - foreach (var renderer in renderers) - { - var materials = renderer.sharedMaterials; - if (materials.Length > 1) - { - Debug.LogError(renderer.name + "材质数量大于1", renderer.gameObject); - continue; - } - var shareMaterial = renderer.sharedMaterial; - if (shareMaterial == null) - { - Debug.LogError(renderer.name + "没有材质", renderer.gameObject); - continue; - } - var shader = shareMaterial.shader; - if (shader == null) - { - Debug.LogError(renderer.name + "没有Shader", renderer.gameObject); - continue; - } - var shaderData = _GetShaderData(shader); - shaderData.AddRenderer(renderer); - } - // 预计算贴图大小 - foreach (var shaderData in _cacheShaders) - { - shaderData.PreCalc(); - } - } - - private void _CollectMeshs(List renderers) - { - _totalCount = 0; - _cacheMeshes.Clear(); - foreach (var renderer in renderers) - { - var meshFilter = renderer.GetComponent(); - if (meshFilter == null) - { - Debug.LogError(renderer.name + "没有MeshFilter", renderer.gameObject); - continue; - } - var mesh = meshFilter.sharedMesh; - if (mesh == null) - { - Debug.LogError(renderer.name + "没有Mesh", renderer.gameObject); - continue; - } - var meshData = _GetMeshData(mesh); - _totalCount += mesh.vertexCount; - meshData.AddObj(renderer.gameObject); - } - } - - private AutoCombieShaderData _GetShaderData(Shader shader) - { - foreach (var shaderData in _cacheShaders) - { - if (shaderData.shader == shader) - { - return shaderData; - } - } - - var newShaderData = new AutoCombieShaderData(shader, _forceUnitTextureSize); - _cacheShaders.Add(newShaderData); - return newShaderData; - } - - private AutoCombieMeshData _GetMeshData(Mesh mesh) - { - foreach (var meshData in _cacheMeshes) - { - if (meshData.mesh == mesh) - { - return meshData; - } - } - - var newMeshData = new AutoCombieMeshData(mesh); - _cacheMeshes.Add(newMeshData); - return newMeshData; - } - - } -} diff --git a/Forest/Assets/PhxhSDK/Editor/AutoCombine/Performance/PerformanceWindow.cs.meta b/Forest/Assets/PhxhSDK/Editor/AutoCombine/Performance/PerformanceWindow.cs.meta deleted file mode 100644 index 50bf18f..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AutoCombine/Performance/PerformanceWindow.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 90dcfacca7654dee9b981e0bd4238416 -timeCreated: 1703670909 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/AutoCombine/Performance/SceneCombineUtil.cs b/Forest/Assets/PhxhSDK/Editor/AutoCombine/Performance/SceneCombineUtil.cs deleted file mode 100644 index c54f7db..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AutoCombine/Performance/SceneCombineUtil.cs +++ /dev/null @@ -1,164 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using Performance.Data; -using PhxhSDK; -using UnityEngine; - -public class SceneCombineUtil : Singlenton -{ - private int _totalCount; - private List _cacheMeshes = new List(); - private List _cacheShaders = new List(); - private int _forceUnitTextureSize = 256; - - public List CombineGameObjects(List renderers,Transform root,string outputPath,int postProcessTextureUnitSize = 256) - { - _forceUnitTextureSize = postProcessTextureUnitSize; - _CollectMeshs(renderers); - _CollectShaders(renderers); - return _DoCombie(root,outputPath); - } - - private List _DoCombie(Transform root,string outputPath) - { - // 强制替换 - // if (_cacheRootObj == null) - // { - // var findObj = GameObject.Find("CombieRoot"); - // if (findObj != null) - // { - // DestroyImmediate(findObj); - // } - // } - // else - // { - // DestroyImmediate(_cacheRootObj); - // } - //_cacheRootObj = new GameObject("CombieRoot"); - - List result = new(); - - for (int i = 0; i < _cacheShaders.Count; i++) - { - var shaderData = _cacheShaders[i]; - var combieObj = shaderData.CombieToOneObj(outputPath); - if (combieObj != null) - { - result.Add(combieObj); - combieObj.transform.SetParent(root); - } - //combieObj.transform.SetParent(_cacheRootObj.transform); - } - - return result; - // 隐藏原始节点 - //_SetOldObjActive(false); - //AssetDatabase.Refresh(); - } - - private void _CollectShaders(List renderers) - { - _cacheShaders.Clear(); - foreach (var renderer in renderers) - { - var materials = renderer.sharedMaterials; - if (materials.Length > 1) - { - Debug.LogError(renderer.name + "材质数量大于1", renderer.gameObject); - continue; - } - - var shareMaterial = renderer.sharedMaterial; - if (shareMaterial == null) - { - Debug.LogError(renderer.name + "没有材质", renderer.gameObject); - continue; - } - - var shader = shareMaterial.shader; - if (shader == null) - { - Debug.LogError(renderer.name + "没有Shader", renderer.gameObject); - continue; - } - - var shaderData = _GetShaderData(shader); - shaderData.AddRenderer(renderer); - } - - // 预计算贴图大小 - foreach (var shaderData in _cacheShaders) - { - shaderData.PreCalc(); - } - } - - private List _CollectRenderers(List gameObjects) - { - var result = new List(); - foreach (var go in gameObjects) - { - var renderer = go.GetComponent(); - if (renderer != null) - result.Add(renderer); - } - - return result; - } - - private void _CollectMeshs(List renderers) - { - _totalCount = 0; - _cacheMeshes.Clear(); - foreach (var renderer in renderers) - { - var meshFilter = renderer.GetComponent(); - if (meshFilter == null) - { - Debug.LogError(renderer.name + "没有MeshFilter", renderer.gameObject); - continue; - } - - var mesh = meshFilter.sharedMesh; - if (mesh == null) - { - Debug.LogError(renderer.name + "没有Mesh", renderer.gameObject); - continue; - } - - var meshData = _GetMeshData(mesh); - _totalCount += mesh.vertexCount; - meshData.AddObj(renderer.gameObject); - } - } - - private AutoCombieShaderData _GetShaderData(Shader shader) - { - foreach (var shaderData in _cacheShaders) - { - if (shaderData.shader == shader) - { - return shaderData; - } - } - - var newShaderData = new AutoCombieShaderData(shader, _forceUnitTextureSize); - _cacheShaders.Add(newShaderData); - return newShaderData; - } - - private AutoCombieMeshData _GetMeshData(Mesh mesh) - { - foreach (var meshData in _cacheMeshes) - { - if (meshData.mesh == mesh) - { - return meshData; - } - } - - var newMeshData = new AutoCombieMeshData(mesh); - _cacheMeshes.Add(newMeshData); - return newMeshData; - } -} \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/AutoCombine/Performance/SceneCombineUtil.cs.meta b/Forest/Assets/PhxhSDK/Editor/AutoCombine/Performance/SceneCombineUtil.cs.meta deleted file mode 100644 index fdf4c89..0000000 --- a/Forest/Assets/PhxhSDK/Editor/AutoCombine/Performance/SceneCombineUtil.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4923e8f03afee074d96c8e493cd939c6 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/Build.meta b/Forest/Assets/PhxhSDK/Editor/Build.meta deleted file mode 100644 index c32421d..0000000 --- a/Forest/Assets/PhxhSDK/Editor/Build.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 4085b97952069c34590b8f21f764d719 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/Build/AddressableBuildBase.cs b/Forest/Assets/PhxhSDK/Editor/Build/AddressableBuildBase.cs deleted file mode 100644 index ab5ac62..0000000 --- a/Forest/Assets/PhxhSDK/Editor/Build/AddressableBuildBase.cs +++ /dev/null @@ -1,192 +0,0 @@ -#if USE_ADDRESSABLES -using System; -using UnityEditor; -using UnityEngine; -using System.Linq; -using DG.DemiEditor; -using UnityEditor.Build.Reporting; -using UnityEditor.AddressableAssets; -using UnityEditor.AddressableAssets.Build; -using UnityEditor.AddressableAssets.Settings; -using UnityEditor.AddressableAssets.Settings.GroupSchemas; - -public class BuildParam -{ - public AddressableAssetSettings Settings; - public IDataBuilder Builder; - public BuildTarget BuildTargetPlatform; - public string AppVersion; - public string ProfileID; - public string WorkSpace; - public string BuildName; - public string AppName; - public string BuildPath; - public bool ClearCached; - public string[] Groups; - public bool EnableHotUpdate; - public bool DevelopmentBuild; - public bool BuildAab; -} - -public static class BuildInfo -{ - public static string BuildScript = "Assets/AddressableAssetsData/DataBuilders/BuildScriptPackedMode.asset"; - public static string SettingsAsset = "Assets/AddressableAssetsData/AddressableAssetSettings.asset"; - public static string GroupName = "Content Update"; - public static string DefaultProfile = "Debug"; - public static string TargetBinPath => string.Format(BinPath, EditorUserBuildSettings.activeBuildTarget); - private const string BinPath = "Assets/AddressableAssetsData/{0}/addressables_content_state.bin"; -} - -public class AddressableBuildBase -{ - public static BuildParam BuildParam = new BuildParam(); - - /// - /// 构建Addressable - /// - public static void BuildAddressable() - { - AddressableAssetSettings.BuildPlayerContent(out var result); - - if (!string.IsNullOrEmpty(result.Error)) - DebugUtil.LogError("Addressable build error encountered: {0}", result.Error); - } - - /// - /// 构建Addressable和Player - /// - public static void BuildContentAndPlayer(BuildPlayerOptions buildOptions) - { - AddressableAssetSettings.BuildPlayerContent(out var result); - if (!string.IsNullOrEmpty(result.Error)) - throw new Exception(result.Error); - - var buildReport - = BuildPipeline.BuildPlayer(buildOptions); - if (buildReport.summary.result != BuildResult.Succeeded) - DebugUtil.LogError($"build summary:{buildReport.summary}"); - } - - /// - /// Addressable 增量更新 - /// - public static void UpdatePreviousBuild() - { - var input = new AddressablesDataBuilderInput(BuildParam.Settings); - - //受到修改的Addressable资源 - var modifiedAssetsList = - ContentUpdateScript.GatherModifiedEntries(BuildParam.Settings, BuildInfo.TargetBinPath); - if (modifiedAssetsList.Count > 0) - { - foreach (var entry in modifiedAssetsList) entry.FlaggedDuringContentUpdateRestriction = false; - ContentUpdateScript.CreateContentUpdateGroup(BuildParam.Settings, modifiedAssetsList, BuildInfo.GroupName); - } - - var cacheData = ContentUpdateScript.LoadContentState(BuildInfo.TargetBinPath); - if (cacheData != null) - { - input.PlayerVersion = cacheData.playerVersion; - input.PreviousContentState = cacheData; - } - - //settings = input.AddressableSettings; - - BuildParam.Builder.BuildData(input); - - AssetDatabase.Refresh(); - } - - /// - /// 构建修改的EditorUserBuildSettings相关设置 - /// - public static void ApplyPlayerSettings() - { - EditorUserBuildSettings.SwitchActiveBuildTarget( - BuildPipeline.GetBuildTargetGroup(BuildParam.BuildTargetPlatform), - BuildParam.BuildTargetPlatform); - - if (BuildParam.BuildTargetPlatform.Equals(BuildTarget.Android)) - { - EditorUserBuildSettings.buildAppBundle = BuildParam.BuildAab; - EditorUserBuildSettings.exportAsGoogleAndroidProject = false; - EditorUserBuildSettings.androidCreateSymbols = AndroidCreateSymbols.Public; - } - - if (BuildParam.DevelopmentBuild) - EditorUserBuildSettings.development = true; - - if (!BuildParam.AppVersion.IsNullOrEmpty()) - PlayerSettings.bundleVersion = BuildParam.AppVersion; - PlayerSettings.productName = BuildParam.AppName; - } - - /// - /// 构建的相关设置 - /// - public static void ApplyBuildSettings() - { - BuildParam.Settings = AddressableAssetSettingsDefaultObject.Settings; - BuildParam.Builder = AssetDatabase.LoadAssetAtPath(BuildInfo.BuildScript) as IDataBuilder; - - ApplyProfile(BuildParam.ProfileID, BuildParam.WorkSpace); - if (BuildParam.ClearCached) BuildParam.Builder?.ClearCachedData(); - ApplyAddressableGroupSetting(BuildParam.Groups); - - BuildParam.Settings.ActivePlayerDataBuilderIndex = - BuildParam.Settings.DataBuilders.IndexOf((ScriptableObject)BuildParam.Builder); - } - - /// - /// 更改Addressable构建模式 - /// - private static void ApplyProfile(string profile, string workSpace) - { - var profileId = BuildParam.Settings.profileSettings.GetProfileId(profile); - if (string.IsNullOrEmpty(profileId)) - { - BuildParam.Settings.activeProfileId = - BuildParam.Settings.profileSettings.GetProfileId(BuildInfo.DefaultProfile); - DebugUtil.LogError("!! Error : Couldn't find a profile named, {0}, " + - "using current profile instead.", profile); - } - else - { - BuildParam.Settings.activeProfileId = profileId; - //设置Addressable Profile里的参数 - BuildParam.Settings.profileSettings.SetValue(profileId, "WorkSpace", workSpace); - DebugUtil.Log("-Profile : {0}, WorkSpace: {1}", profile, workSpace); - } - } - - /// - /// Addressable组的设置 单独打包 - /// - private static void ApplyAddressableGroupSetting(string[] groups) - { - if (groups == null) - { - foreach (var group in BuildParam.Settings.groups) - { - var schema = group.GetSchema(); - if (schema != null) - schema.IncludeInBuild = true; - } - } - else - { - foreach (var group in BuildParam.Settings.groups) - { - var schema = group.GetSchema(); - if (schema != null) - { - schema.IncludeInBuild = groups.Contains(group.Name); - DebugUtil.Log("-IncludeBuild : {0} included in the build : {1}", group.Name, - groups.Contains(group.Name)); - } - } - } - } -} -#endif \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/Build/AddressableBuildBase.cs.meta b/Forest/Assets/PhxhSDK/Editor/Build/AddressableBuildBase.cs.meta deleted file mode 100644 index d2f2588..0000000 --- a/Forest/Assets/PhxhSDK/Editor/Build/AddressableBuildBase.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ec0252c5e60b87740bdf596096463f1d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/Build/BuildUtils.cs b/Forest/Assets/PhxhSDK/Editor/Build/BuildUtils.cs deleted file mode 100644 index f3bcb12..0000000 --- a/Forest/Assets/PhxhSDK/Editor/Build/BuildUtils.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.IO; - -public class BuildUtils -{ - public static void SetFileReadable(string path) - { - if (File.Exists(path)) - { - if ((File.GetAttributes(path) & FileAttributes.ReadOnly) != 0) - File.SetAttributes(path, FileAttributes.Normal); - } - else if (Directory.Exists(path)) - { - SetFilesReadable(path); - } - else - { - throw new ArgumentException("Invalid path: " + path); - } - } - - /// - /// 递归取消文件夹内容只读 - /// - private static void SetFilesReadable(string path) - { - foreach (var filePath in Directory.GetFiles(path)) - if ((File.GetAttributes(filePath) & FileAttributes.ReadOnly) != 0) - File.SetAttributes(filePath, FileAttributes.Normal); - - foreach (var subFolderPath in Directory.GetDirectories(path)) SetFilesReadable(subFolderPath); - } - - public static void CopyPathFiles(string srcPath, string targetPath) - { - var allFiles = Directory.GetFiles(srcPath, "*.*", SearchOption.AllDirectories); - foreach (var file in allFiles) - { - var targetFile = file.Replace(srcPath, targetPath); - var targetDir = Path.GetDirectoryName(targetFile); - if (!Directory.Exists(targetDir)) - { - Directory.CreateDirectory(targetDir); - } - - File.Copy(file, targetFile, true); - } - } - - public static bool ConvertBool(string value) - { - return value == "true"; - } -} \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/Build/BuildUtils.cs.meta b/Forest/Assets/PhxhSDK/Editor/Build/BuildUtils.cs.meta deleted file mode 100644 index b918d8b..0000000 --- a/Forest/Assets/PhxhSDK/Editor/Build/BuildUtils.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8677d92903ce34b4da6169f0e8a9777d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/Build/YooAssetBuildBase.cs b/Forest/Assets/PhxhSDK/Editor/Build/YooAssetBuildBase.cs deleted file mode 100644 index 1bf36c0..0000000 --- a/Forest/Assets/PhxhSDK/Editor/Build/YooAssetBuildBase.cs +++ /dev/null @@ -1,569 +0,0 @@ -using System; -using System.IO; -using UnityEditor; -using UnityEngine; -using DG.DemiEditor; -using PhxhSDK.Editor; -using YooAsset.Editor; -using System.Diagnostics; -using Debug = UnityEngine.Debug; -using PhxhSDK.AOT.VersionUpdate; -using BuildResult = UnityEditor.Build.Reporting.BuildResult; - -internal class YooAssetBuildBase -{ - /// - ///默认打包参数 - /// - public static BuildTarget BuildTargetPlatform = BuildTarget.Android; - - //AllLocal 全本地 - public static string profileName = "Debug"; - - public static string appVersion; - - public static string workSpace; - - private static bool buildAAB; - - private static string pathprefix = "Builds"; - - private static string buildName = "tempName"; - - private static string pathSuffix = ""; - - private const string OutPutPath = "{0}/{1}{2}"; - - private static bool enableHotUpdate; - - //资源路径 - private static string resourcePath; - - private static string profileID; - - #region YooAsset 资源构建相关 - - private static bool BuildYooAsset(BuildTarget buildTarget, string profileName, string version, - string workSpace, string remoteUser = null, string remoteHost = null, string remotePath = null) - { - // 读取打包次数 - var buildCount = PackDataInst.ReadBuildCount(workSpace, version); - Debug.Log($"当前打包次数:{buildCount}"); - - // 构建参数 - var defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot(); - var defaultStreammingAssetsRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot(); - var buildParameters = new BuiltinBuildParameters(); - buildParameters.BuildOutputRoot = defaultOutputRoot; - buildParameters.BuildinFileRoot = defaultStreammingAssetsRoot; - buildParameters.BuildTarget = buildTarget; - buildParameters.BuildMode = EBuildMode.ForceRebuild; - buildParameters.PackageName = "DefaultPackage"; - buildParameters.PackageVersion = $"{version}_{buildCount}"; - buildParameters.VerifyBuildingResult = true; - buildParameters.EnableSharePackRule = true; - buildParameters.CompressOption = ECompressOption.LZ4; - buildParameters.FileNameStyle = EFileNameStyle.BundleName_HashName; - buildParameters.EncryptionServices = new YooEncryptFS(); - - var needUpload = false; - if (profileName.Equals("AllLocal")) - { - Debug.Log("分包模式-全本地"); - // 全本地 - buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.ClearAndCopyAll; - } - else - { - Debug.Log("分包模式-全远程"); - buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.ClearAndCopyByTags; - buildParameters.BuildinFileCopyParams = "local"; - needUpload = true; - } - - if (Directory.Exists(defaultOutputRoot)) - { - Directory.Delete(defaultOutputRoot, true); - } - - if (Directory.Exists(defaultStreammingAssetsRoot)) - { - Directory.Delete(defaultStreammingAssetsRoot, true); - } - - // 执行构建 - var builder = new BuiltinBuildPipeline(); - var buildResult = builder.Run(buildParameters, true); - if (buildResult.Success) - { - Debug.Log($"构建成功 : {buildResult.OutputPackageDirectory}"); - - Debug.Log($"开始构建raw资源"); - var resultRaw = BuildRawAsset(buildTarget, profileName, version, workSpace); - if (!resultRaw.Success) - { - Debug.LogError("构建raw资源失败"); - } - else - { - Debug.Log("构建raw资源成功"); - } - - // 把资源拷贝到/ServerData/[BuildTarget]目录下 - Debug.Log("开始拷贝资源"); - var assetsPath = Application.dataPath; - var buildPath = assetsPath.Replace("/Assets", $"/ServerData/{buildTarget}"); - if (Directory.Exists(buildPath)) - { - Directory.Delete(buildPath, true); - } - - var serverDataPath = assetsPath.Replace("/Assets", "/ServerData"); - if (!Directory.Exists(serverDataPath)) - { - Directory.CreateDirectory(serverDataPath); - } - - FileUtil.CopyFileOrDirectory(buildResult.OutputPackageDirectory, buildPath); - Debug.Log($"拷贝默认资源到{buildPath}成功"); - - BuildUtils.CopyPathFiles(resultRaw.OutputPackageDirectory, buildPath); - Debug.Log($"拷贝raw资源到{buildPath}成功"); - - resourcePath = buildResult.OutputPackageDirectory; - // 上传至远程服务器 - // TODO: 使用外部上传 - // if (needUpload) - // { - // UploadToServerYooAsset(version, buildTarget, buildResult.OutputPackageDirectory, remoteUser, remoteHost, remotePath); - // } - return true; - } - else - { - Debug.LogError($"构建失败 : {buildResult.FailedTask} {buildResult.ErrorInfo}"); - return false; - } - } - - private static YooAsset.Editor.BuildResult BuildRawAsset(BuildTarget buildTarget, string profileName, - string version, - string workSpace) - { - // 读取打包次数 - var buildCount = PackDataInst.ReadBuildCount(workSpace, version); - // var buildCount = 1; - Debug.Log($"当前打包次数:{buildCount}"); - - // 构建参数 - var defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot(); - var defaultStreammingAssetsRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot(); - var buildParameters = new RawFileBuildParameters(); - buildParameters.BuildOutputRoot = defaultOutputRoot; - buildParameters.BuildinFileRoot = defaultStreammingAssetsRoot; - buildParameters.BuildTarget = buildTarget; - buildParameters.BuildMode = EBuildMode.ForceRebuild; - buildParameters.PackageName = "RawPackage"; - buildParameters.PackageVersion = $"{version}_{buildCount}"; - buildParameters.VerifyBuildingResult = true; - buildParameters.EnableSharePackRule = false; - buildParameters.FileNameStyle = EFileNameStyle.BundleName_HashName; - buildParameters.EncryptionServices = new YooEncryptNone(); - buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None; - buildParameters.BuildPipeline = "RawFileBuildPipeline"; - - if (profileName.Equals("AllLocal")) - { - // 全本地 - buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.OnlyCopyAll; - } - - var builder = new RawFileBuildPipeline(); - var buildResult = builder.Run(buildParameters, true); - - return buildResult; - } - - #endregion - - #region 批处理 - - /// - /// 初始化设置 - /// - /// 是否热更 - public static bool Init() - { - InitializationSettings(); - return enableHotUpdate; - } - - /// - /// 批处理构建Resource和Player - /// - public static void BuildContentAndPlayer() - { - //Init(); - var isUseYooAsset = workSpace == "DevYoo"; -#if USE_YOO - isUseYooAsset = true; -#endif - - if (isUseYooAsset) - { - Debug.Log("使用YooAsset打包"); - var result = BuildYooAsset(BuildTargetPlatform, profileName, appVersion, workSpace); - if (!result) - { - Debug.LogError("打包资源失败"); - throw new Exception("YooAsset打包资源失败"); - } - } - - if (BuildTargetPlatform.Equals(BuildTarget.Android)) - { - EditorUserBuildSettings.buildAppBundle = buildAAB; - EditorUserBuildSettings.exportAsGoogleAndroidProject = false; - EditorUserBuildSettings.androidCreateSymbols = AndroidCreateSymbols.Public; - } - - //Build BuildPlayer - BuildPlayerInBatch(); - } - - /// - /// 批处理下只构建Player - /// - private static void BuildPlayerInBatch() - { - var buildOptions = BuildOptions.None; - if (EditorUserBuildSettings.development) - buildOptions |= BuildOptions.Development; - - BuildPlayerOptions buildPlayerOption = new(); - buildPlayerOption.options = buildOptions; - buildPlayerOption.locationPathName = string.Format(OutPutPath, pathprefix, buildName, pathSuffix); - buildPlayerOption.scenes = GetScenes(); - buildPlayerOption.target = EditorUserBuildSettings.activeBuildTarget; - - var buildReport - = BuildPipeline.BuildPlayer(buildPlayerOption); - if (buildReport.summary.result != BuildResult.Succeeded) - Debug.LogError($"build summary:{buildReport.summary}"); - } - - /// - /// 更新资源 - /// - public static void BuildOnlyResUpdate() - { - var isUseYooAsset = workSpace == "DevYoo"; -#if USE_YOO - isUseYooAsset = true; -#endif - if (isUseYooAsset) - { - // YooAsset - Debug.Log("使用YooAsset打包"); - Debug.Log( - $"打包参数: _buildTargetPlatform:{BuildTargetPlatform}, profileName:{profileName}, appVersion:{appVersion}, workSpace:{workSpace}"); - - // 读取打包次数 - var buildCount = PackDataInst.ReadBuildCount(workSpace, appVersion); - Debug.Log($"当前打包次数:{buildCount}"); - // 更新打包次数 - buildCount++; - PackDataInst.CreateBuildCount(workSpace, appVersion, buildCount); - - var result = BuildYooAsset(BuildTargetPlatform, profileName, appVersion, workSpace); - if (!result) - { - Debug.LogError("打包资源失败"); - throw new Exception("YooAsset打包资源失败"); - } - } - } - - #endregion - - #region 编辑器 - - //编辑器下参数 - public static bool developmentBuild; - - /// - /// 编辑器下构建YooAsset资源 - /// - public static void BuildResourceInEditor() - { - Debug.Log("使用YooAsset构建资源"); - var result = BuildYooAsset(BuildTargetPlatform, profileName, appVersion, workSpace); - if (!result) - { - Debug.LogError("打包资源失败"); - throw new Exception("YooAsset打包资源失败"); - } - } - - public static void BuildContentAndPlayerInEditor(string remoteUser = null, string remoteHost = null, - string remotePath = null) - { - //Init(); - var isUseYooAsset = workSpace == "DevYoo"; -#if USE_YOO - isUseYooAsset = true; -#endif - - if (isUseYooAsset) - { - Debug.Log("使用YooAsset打包"); - var result = BuildYooAsset(BuildTargetPlatform, profileName, appVersion, workSpace); - if (!result) - { - Debug.LogError("打包资源失败"); - throw new Exception("YooAsset打包资源失败"); - } - - if (!profileName.Equals("AllLocal")) - { - UploadToServerYooAsset(workSpace, appVersion, BuildTargetPlatform, - remoteUser, remoteHost, remotePath); - } - } - - if (BuildTargetPlatform.Equals(BuildTarget.Android)) - { - EditorUserBuildSettings.buildAppBundle = buildAAB; - EditorUserBuildSettings.exportAsGoogleAndroidProject = false; - EditorUserBuildSettings.androidCreateSymbols = AndroidCreateSymbols.Public; - } - - //Build BuildPlayer - BuildPlayerInBatch(); - } - - /// - /// 编辑器下只构建Player - /// - public static void BuildPlayerInEditor() - { - try - { - var options = new BuildPlayerOptions(); - EditorUserBuildSettings.development = developmentBuild; - var playerSettings = BuildPlayerWindow.DefaultBuildMethods.GetBuildPlayerOptions(options); - playerSettings.target = BuildTargetPlatform; - playerSettings.options |= BuildOptions.CleanBuildCache; - if (BuildTargetPlatform.Equals(BuildTarget.Android)) - { - EditorUserBuildSettings.exportAsGoogleAndroidProject = false; - EditorUserBuildSettings.androidCreateSymbols = AndroidCreateSymbols.Public; - } - - BuildPipeline.BuildPlayer(playerSettings); - } - catch (Exception e) - { - Debug.LogError($" build player failed exception:{e.Message} \r\n {e.StackTrace}"); - } - } - - #endregion - - /// - /// 判断命令行参数 - /// - private static void InitializationSettings() - { - var args = Environment.GetCommandLineArgs(); - - for (var i = 0; i < args.Length; i++) - switch (args[i]) - { - case "-platform": - JudgmentPlatform(args[i + 1]); - break; - case "-appVersion": - PlayerSettings.bundleVersion = args[i + 1]; - appVersion = args[i + 1]; - break; - case "-profile": - profileName = args[i + 1]; - break; - case "-channel": - workSpace = args[i + 1]; - break; - case "-buildName": - buildName = args[i + 1]; - break; - case "-appName": - PlayerSettings.productName = args[i + 1]; - break; - case "-outpath": - { - Directory.CreateDirectory(args[i + 1]); - pathprefix = args[i + 1]; - break; - } - case "-enableHotUpdate": - enableHotUpdate = BuildUtils.ConvertBool(args[i + 1]); - break; - case "-developmentBuild": - EditorUserBuildSettings.development = BuildUtils.ConvertBool(args[i + 1]); - break; - case "-aab": - buildAAB = BuildUtils.ConvertBool(args[i + 1]); - break; - } - } - - /// - /// 判断打包平台参数 - /// - public static void JudgmentPlatform(string platform) - { - switch (platform) - { - case "iOS": - { - BuildTargetPlatform = BuildTarget.iOS; - pathSuffix = ""; - break; - } - default: - { - BuildTargetPlatform = BuildTarget.Android; - if (EditorUserBuildSettings.buildAppBundle) - { - pathSuffix = ".aab"; - } - else - { - pathSuffix = ".apk"; - } - - break; - } - } - - EditorUserBuildSettings.SwitchActiveBuildTarget(BuildPipeline.GetBuildTargetGroup(BuildTargetPlatform), - BuildTargetPlatform); - } - - private static string[] GetScenes() - { - var scenes = EditorBuildSettings.scenes; - if (scenes != null && scenes.Length > 0) - { - var scenesName = new string[scenes.Length]; - for (int i = 0; i < scenes.Length; i++) - { - scenesName[i] = scenes[i].path; - } - - return scenesName; - } - - return null; - } - - /// - /// 上传服务器 YooAsset - /// - public static void UploadToServerYooAsset(string workSpace, string version, BuildTarget buildTarget, - string remoteUser, string remoteHost, - string remotePath) - { - if (remoteUser == null) return; - if (string.IsNullOrEmpty(resourcePath)) - { - DebugUtil.LogError("资源路径为空"); - return; - } - - var assetsPath = resourcePath; - - var buildPath = assetsPath; - - if (workSpace.IsNullOrEmpty()) workSpace = "WorkSpace"; - - var uploadToPath = string.Format(remotePath, workSpace, buildTarget.ToString(), version); - - DebugUtil.LogWarning(uploadToPath); - - // 创建压缩文件 - Process.Start("tar", $"-czvf upload.tgz -C \"{buildPath}\" .")?.WaitForExit(); - - // 创建远程目录 - Process.Start("ssh", $"{remoteUser}@{remoteHost} \"mkdir -p {uploadToPath}\"")?.WaitForExit(); - - // 将上传至远程主机 - Process.Start("scp", $"upload.tgz {remoteUser}@{remoteHost}:{uploadToPath}")?.WaitForExit(); - - // 在远程主机上解压文件 - Process.Start("ssh", - $"{remoteUser}@{remoteHost} \"cd {uploadToPath}; tar -xzvf upload.tgz; rm -rf upload.tgz\"") - ?.WaitForExit(); - } - - public static void CollectSVC(Action waitAction) - { - var savePath = "Assets/Config/ShaderVariants/MyShaderVariants.shadervariants"; - Action completedCallback = () => - { - ShaderVariantCollection collection = - AssetDatabase.LoadAssetAtPath(savePath); - if (collection != null) - { - Debug.Log("收集shader变种成功"); - Debug.Log($"ShaderCount : {collection.shaderCount}"); - Debug.Log($"VariantCount : {collection.variantCount}"); - - waitAction?.Invoke(); - } - else - { - throw new Exception("收集shader变种失败"); - } - - // EditorTools.CloseUnityGameWindow(); - // EditorApplication.Exit(0); - }; - ShaderVariantCollector.Run(savePath, "DefaultPackage", 1000, completedCallback); - } - - [MenuItem("Test/YooAsset/测试打包")] - public static void TestBuildYooAsset() - { - BuildYooAsset(BuildTarget.Android, "Debug", "0.2.0", "LT"); - } - - [MenuItem("Test/YooAsset/测试构建Raw资源")] - private static void _TestFunc() - { - var buildTarget = BuildTarget.Android; - var resultRaw = YooAssetBuildBase.BuildRawAsset(buildTarget, "Debug", "0.2.0", "Dev"); - if (!resultRaw.Success) - { - Debug.LogError("构建raw资源失败"); - } - else - { - Debug.Log("构建raw资源成功"); - - Debug.Log("输出路径:" + resultRaw.OutputPackageDirectory); - - Debug.Log("开始拷贝资源"); - var assetsPath = Application.dataPath; - var buildPath = assetsPath.Replace("/Assets", $"/ServerData/{buildTarget}"); - var serverDataPath = assetsPath.Replace("/Assets", "/ServerData"); - if (!Directory.Exists(serverDataPath)) - { - Directory.CreateDirectory(serverDataPath); - } - - BuildUtils.CopyPathFiles(resultRaw.OutputPackageDirectory, buildPath); - Debug.Log($"拷贝raw资源到{buildPath}成功"); - } - } -} \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/Build/YooAssetBuildBase.cs.meta b/Forest/Assets/PhxhSDK/Editor/Build/YooAssetBuildBase.cs.meta deleted file mode 100644 index a28f2d2..0000000 --- a/Forest/Assets/PhxhSDK/Editor/Build/YooAssetBuildBase.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0b7b5a9c4a9b3bc46b1b6a5f798513f4 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/EditorUtils.cs b/Forest/Assets/PhxhSDK/Editor/EditorUtils.cs deleted file mode 100644 index 65464e5..0000000 --- a/Forest/Assets/PhxhSDK/Editor/EditorUtils.cs +++ /dev/null @@ -1,48 +0,0 @@ -using UnityEditor; - -namespace PhxhSDK.Editor -{ - public static class EditorUtils - { - public static void ApplyBuildPlayerSettings() - { - _ApplyCommonSettings(); - _ApplyOnlyBuildPlayerSettings(); - - } - - public static void ApplyBuildContentSettings() - { - _ApplyCommonSettings(); - _ApplyOnlyBuildContentSettings(); - } - - public static void ApplyBuildContentAndPlayerSettings() - { - _ApplyCommonSettings(); - _ApplyOnlyBuildPlayerSettings(); - _ApplyOnlyBuildContentSettings(); - } - - - private static void _ApplyOnlyBuildPlayerSettings() - { - // todo - } - - private static void _ApplyOnlyBuildContentSettings() - { - // todo - } - - private static void _ApplyCommonSettings() - { - var options = new BuildPlayerOptions(); - var playerSettings = BuildPlayerWindow.DefaultBuildMethods.GetBuildPlayerOptions(options); - playerSettings.target = PhxhBuildParam.target; - - // todo - - } - } -} \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/EditorUtils.cs.meta b/Forest/Assets/PhxhSDK/Editor/EditorUtils.cs.meta deleted file mode 100644 index f006144..0000000 --- a/Forest/Assets/PhxhSDK/Editor/EditorUtils.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 78db816c2cf84edc9f40c91f1a228bfc -timeCreated: 1706171452 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/PhxhBuild.cs b/Forest/Assets/PhxhSDK/Editor/PhxhBuild.cs deleted file mode 100644 index 1f1891c..0000000 --- a/Forest/Assets/PhxhSDK/Editor/PhxhBuild.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; - -namespace PhxhSDK.Editor -{ - public static class PhxhBuild - { - public static Action beforeBuildPlayer; // handle other things for special game - - public static Action beforeBuildContent; // handle other things for special game - - public static Action beforeBuildContentAndPlayer; // handle other things for special game - - - public static void BuildPlayer() - { - EditorUtils.ApplyBuildPlayerSettings(); - - beforeBuildPlayer?.Invoke(); - - // build call - } - - public static void BuildContent() - { - EditorUtils.ApplyBuildContentSettings(); - - beforeBuildContent?.Invoke(); - - // build call - } - - public static void BuildContentAndPlayer() - { - EditorUtils.ApplyBuildContentSettings(); - - beforeBuildContentAndPlayer?.Invoke(); - - // build call - } - } -} \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/PhxhBuild.cs.meta b/Forest/Assets/PhxhSDK/Editor/PhxhBuild.cs.meta deleted file mode 100644 index 08eb881..0000000 --- a/Forest/Assets/PhxhSDK/Editor/PhxhBuild.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: bea40437e9e44ab5aba6802170d4a449 -timeCreated: 1706170047 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/PhxhBuildParam.cs b/Forest/Assets/PhxhSDK/Editor/PhxhBuildParam.cs deleted file mode 100644 index 6da18ac..0000000 --- a/Forest/Assets/PhxhSDK/Editor/PhxhBuildParam.cs +++ /dev/null @@ -1,9 +0,0 @@ -using UnityEditor; - -namespace PhxhSDK.Editor -{ - public static class PhxhBuildParam - { - public static BuildTarget target; - } -} \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/PhxhBuildParam.cs.meta b/Forest/Assets/PhxhSDK/Editor/PhxhBuildParam.cs.meta deleted file mode 100644 index 1fb3bbe..0000000 --- a/Forest/Assets/PhxhSDK/Editor/PhxhBuildParam.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 138e7180f2e44142a8aac6753c01740c -timeCreated: 1706170386 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/RecycleView.meta b/Forest/Assets/PhxhSDK/Editor/RecycleView.meta deleted file mode 100644 index 6f23bf0..0000000 --- a/Forest/Assets/PhxhSDK/Editor/RecycleView.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 62074c38e9e4b9243b75aa93b588da8d -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/RecycleView/ExpandableViewEditor.cs b/Forest/Assets/PhxhSDK/Editor/RecycleView/ExpandableViewEditor.cs deleted file mode 100644 index 00128aa..0000000 --- a/Forest/Assets/PhxhSDK/Editor/RecycleView/ExpandableViewEditor.cs +++ /dev/null @@ -1,28 +0,0 @@ -using UnityEngine; -using System.Collections; -using UnityEditor; -using UnityEngine.UIElements; -using UnityEditor.UI; - -namespace PhxhSDK -{ - [CustomEditor(typeof(ExpandableView))] - public class ExpandableViewEditor : ScrollRectEditor - { - ExpandableView list; - - public override void OnInspectorGUI() - { - list = (ExpandableView)target; - list.dir = (E_Direction)EditorGUILayout.EnumPopup("Direction: ", list.dir); - - list.lines = EditorGUILayout.IntField("Row Or Column: ", list.lines); - list.squareSpacing = EditorGUILayout.FloatField("Spacing: ", list.squareSpacing); - list.m_ExpandButton = - (GameObject)EditorGUILayout.ObjectField("Cell: ", list.m_ExpandButton, typeof(GameObject), true); - list.cell = (GameObject)EditorGUILayout.ObjectField("ExpandCell: ", list.cell, typeof(GameObject), true); - list.m_IsExpand = EditorGUILayout.ToggleLeft(" isDefaultExpand", list.m_IsExpand); - //list.m_BackgroundMargin = EditorGUILayout.FloatField("BackgroundScale:", list.m_BackgroundMargin); - } - } -} \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/RecycleView/ExpandableViewEditor.cs.meta b/Forest/Assets/PhxhSDK/Editor/RecycleView/ExpandableViewEditor.cs.meta deleted file mode 100644 index 6b859f5..0000000 --- a/Forest/Assets/PhxhSDK/Editor/RecycleView/ExpandableViewEditor.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 834a1ce3c3ce92e438df60267d5368b6 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/RecycleView/RecycleViewEditor.cs b/Forest/Assets/PhxhSDK/Editor/RecycleView/RecycleViewEditor.cs deleted file mode 100644 index 7b1c5be..0000000 --- a/Forest/Assets/PhxhSDK/Editor/RecycleView/RecycleViewEditor.cs +++ /dev/null @@ -1,35 +0,0 @@ -using UnityEngine; -using UnityEditor; -using UnityEditor.UI; - -namespace PhxhSDK -{ - [CustomEditor(typeof(RecycleView))] - public class RecycleViewEditor : UnityEditor.Editor - { - RecycleView rv; - - public override void OnInspectorGUI() - { - rv = (RecycleView)target; - - rv.dir = (E_Direction)EditorGUILayout.EnumPopup("Direction", rv.dir); - rv.lines = EditorGUILayout.IntSlider("Row Or Column", rv.lines, 1, 10); - rv.squareSpacing = EditorGUILayout.FloatField("Square Spacing", rv.squareSpacing); - rv.Spacing = EditorGUILayout.Vector2Field("Spacing", rv.Spacing); - rv.paddingLeft = EditorGUILayout.FloatField("Padding Left", rv.paddingLeft); - rv.paddingTop = EditorGUILayout.FloatField("Padding Top", rv.paddingTop); - - rv.cell = - (GameObject)EditorGUILayout.ObjectField("Cell", rv.cell, typeof(GameObject), true); - // rv.isShowArrow = EditorGUILayout.ToggleLeft("IsShowArrow", rv.isShowArrow); - // if (rv.isShowArrow) - // { - // rv.firstArrow = (GameObject)EditorGUILayout.ObjectField("Up or Left Arrow", - // rv.firstArrow, typeof(GameObject), true); - // rv.endArrow = (GameObject)EditorGUILayout.ObjectField("Down or Right Arrow", - // rv.endArrow, typeof(GameObject), true); - // } - } - } -} \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/RecycleView/RecycleViewEditor.cs.meta b/Forest/Assets/PhxhSDK/Editor/RecycleView/RecycleViewEditor.cs.meta deleted file mode 100644 index e31a588..0000000 --- a/Forest/Assets/PhxhSDK/Editor/RecycleView/RecycleViewEditor.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b172fe086a9d1c3438345211f83b0b31 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/ScrollView.meta b/Forest/Assets/PhxhSDK/Editor/ScrollView.meta deleted file mode 100644 index beb5f46..0000000 --- a/Forest/Assets/PhxhSDK/Editor/ScrollView.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: adaa92c2f64f0ab41960c723dc8eedf5 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/ScrollView/PhxhScrollViewEditor.cs b/Forest/Assets/PhxhSDK/Editor/ScrollView/PhxhScrollViewEditor.cs deleted file mode 100644 index cd305a3..0000000 --- a/Forest/Assets/PhxhSDK/Editor/ScrollView/PhxhScrollViewEditor.cs +++ /dev/null @@ -1,269 +0,0 @@ -// ----------------------------------------------------------------------- -// -// Copyright (c) AillieoTech. All rights reserved. -// -// ----------------------------------------------------------------------- - - - -namespace PhxhSDK -{ - using System; - using System.Linq; - using System.Reflection; - using UnityEditor; - using UnityEditor.UI; - using UnityEngine; - using UnityEngine.UI; - - [CustomEditor(typeof(PhxhScrollView))] - public class PhxhScrollViewEditor : ScrollRectEditor - { - private const string bgPath = "UI/Skin/Background.psd"; - private const string spritePath = "UI/Skin/UISprite.psd"; - private const string maskPath = "UI/Skin/UIMask.psd"; - private static Color panelColor = new Color(1f, 1f, 1f, 0.392f); - private static Color defaultSelectableColor = new Color(1f, 1f, 1f, 1f); - private static Vector2 thinElementSize = new Vector2(160f, 20f); - private static Action PlaceUIElementRoot; - - private SerializedProperty itemTemplate; - private SerializedProperty poolSize; - private SerializedProperty defaultItemSize; - private SerializedProperty layoutType; - - private GUIStyle cachedCaption; - - private GUIStyle caption - { - get - { - if (this.cachedCaption == null) - { - this.cachedCaption = new GUIStyle { richText = true, alignment = TextAnchor.MiddleCenter }; - } - - return this.cachedCaption; - } - } - - public override void OnInspectorGUI() - { - this.serializedObject.Update(); - - EditorGUILayout.BeginVertical("box"); - EditorGUILayout.LabelField("Additional configs", this.caption); - EditorGUILayout.Space(); - this.DrawConfigInfo(); - this.serializedObject.ApplyModifiedProperties(); - EditorGUILayout.EndVertical(); - - EditorGUILayout.BeginVertical("box"); - EditorGUILayout.LabelField("For original ScrollRect", this.caption); - EditorGUILayout.Space(); - base.OnInspectorGUI(); - EditorGUILayout.EndVertical(); - } - - protected static void InternalAddScrollView(MenuCommand menuCommand) - where T : PhxhScrollView - { - GetPrivateMethodByReflection(); - - GameObject root = CreateUIElementRoot(typeof(T).Name, new Vector2(200, 200)); - PlaceUIElementRoot?.Invoke(root, menuCommand); - - GameObject viewport = CreateUIObject("Viewport", root); - GameObject content = CreateUIObject("Content", viewport); - - var parent = menuCommand.context as GameObject; - if (parent != null) - { - root.transform.SetParent(parent.transform, false); - } - - Selection.activeGameObject = root; - - GameObject hScrollbar = CreateScrollbar(); - hScrollbar.name = "Scrollbar Horizontal"; - hScrollbar.transform.SetParent(root.transform, false); - RectTransform hScrollbarRT = hScrollbar.GetComponent(); - hScrollbarRT.anchorMin = Vector2.zero; - hScrollbarRT.anchorMax = Vector2.right; - hScrollbarRT.pivot = Vector2.zero; - hScrollbarRT.sizeDelta = new Vector2(0, hScrollbarRT.sizeDelta.y); - - GameObject vScrollbar = CreateScrollbar(); - vScrollbar.name = "Scrollbar Vertical"; - vScrollbar.transform.SetParent(root.transform, false); - vScrollbar.GetComponent().SetDirection(Scrollbar.Direction.BottomToTop, true); - RectTransform vScrollbarRT = vScrollbar.GetComponent(); - vScrollbarRT.anchorMin = Vector2.right; - vScrollbarRT.anchorMax = Vector2.one; - vScrollbarRT.pivot = Vector2.one; - vScrollbarRT.sizeDelta = new Vector2(vScrollbarRT.sizeDelta.x, 0); - - RectTransform viewportRect = viewport.GetComponent(); - viewportRect.anchorMin = Vector2.zero; - viewportRect.anchorMax = Vector2.one; - viewportRect.sizeDelta = Vector2.zero; - viewportRect.pivot = Vector2.up; - - RectTransform contentRect = content.GetComponent(); - contentRect.anchorMin = Vector2.up; - contentRect.anchorMax = Vector2.one; - contentRect.sizeDelta = new Vector2(0, 300); - contentRect.pivot = Vector2.up; - - PhxhScrollView scrollRect = root.AddComponent(); - scrollRect.content = contentRect; - scrollRect.viewport = viewportRect; - scrollRect.horizontalScrollbar = hScrollbar.GetComponent(); - scrollRect.verticalScrollbar = vScrollbar.GetComponent(); - scrollRect.horizontalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport; - scrollRect.verticalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport; - scrollRect.horizontalScrollbarSpacing = -3; - scrollRect.verticalScrollbarSpacing = -3; - - Image rootImage = root.AddComponent(); - rootImage.sprite = AssetDatabase.GetBuiltinExtraResource(bgPath); - rootImage.type = Image.Type.Sliced; - rootImage.color = panelColor; - - Mask viewportMask = viewport.AddComponent(); - viewportMask.showMaskGraphic = false; - - Image viewportImage = viewport.AddComponent(); - viewportImage.sprite = AssetDatabase.GetBuiltinExtraResource(maskPath); - viewportImage.type = Image.Type.Sliced; - } - - protected override void OnEnable() - { - base.OnEnable(); - - this.itemTemplate = this.serializedObject.FindProperty("itemTemplate"); - this.poolSize = this.serializedObject.FindProperty("poolSize"); - this.defaultItemSize = this.serializedObject.FindProperty("defaultItemSize"); - this.layoutType = this.serializedObject.FindProperty("layoutType"); - } - - protected virtual void DrawConfigInfo() - { - EditorGUILayout.PropertyField(this.itemTemplate); - EditorGUILayout.PropertyField(this.poolSize); - EditorGUILayout.PropertyField(this.defaultItemSize); - this.layoutType.intValue = (int)(PhxhScrollView.ItemLayoutType)EditorGUILayout.EnumPopup("layoutType", (PhxhScrollView.ItemLayoutType)this.layoutType.intValue); - } - - [MenuItem("GameObject/UI/DynamicScrollView", false, 90)] - private static void AddScrollView(MenuCommand menuCommand) - { - InternalAddScrollView(menuCommand); - } - - private static GameObject CreateScrollbar() - { - // Create GOs Hierarchy - GameObject scrollbarRoot = CreateUIElementRoot("Scrollbar", thinElementSize); - GameObject sliderArea = CreateUIObject("Sliding Area", scrollbarRoot); - GameObject handle = CreateUIObject("Handle", sliderArea); - - Image bgImage = scrollbarRoot.AddComponent(); - bgImage.sprite = AssetDatabase.GetBuiltinExtraResource(bgPath); - bgImage.type = Image.Type.Sliced; - bgImage.color = defaultSelectableColor; - - Image handleImage = handle.AddComponent(); - handleImage.sprite = AssetDatabase.GetBuiltinExtraResource(spritePath); - handleImage.type = Image.Type.Sliced; - handleImage.color = defaultSelectableColor; - - RectTransform sliderAreaRect = sliderArea.GetComponent(); - sliderAreaRect.sizeDelta = new Vector2(-20, -20); - sliderAreaRect.anchorMin = Vector2.zero; - sliderAreaRect.anchorMax = Vector2.one; - - RectTransform handleRect = handle.GetComponent(); - handleRect.sizeDelta = new Vector2(20, 20); - - Scrollbar scrollbar = scrollbarRoot.AddComponent(); - scrollbar.handleRect = handleRect; - scrollbar.targetGraphic = handleImage; - SetDefaultColorTransitionValues(scrollbar); - - return scrollbarRoot; - } - - private static GameObject CreateUIElementRoot(string name, Vector2 size) - { - var child = new GameObject(name); - RectTransform rectTransform = child.AddComponent(); - rectTransform.sizeDelta = size; - return child; - } - - private static GameObject CreateUIObject(string name, GameObject parent) - { - var go = new GameObject(name); - go.AddComponent(); - SetParentAndAlign(go, parent); - return go; - } - - private static void SetParentAndAlign(GameObject child, GameObject parent) - { - if (parent == null) - { - return; - } - - child.transform.SetParent(parent.transform, false); - SetLayerRecursively(child, parent.layer); - } - - private static void SetLayerRecursively(GameObject go, int layer) - { - go.layer = layer; - Transform t = go.transform; - for (var i = 0; i < t.childCount; i++) - { - SetLayerRecursively(t.GetChild(i).gameObject, layer); - } - } - - private static void SetDefaultColorTransitionValues(Selectable slider) - { - ColorBlock colors = slider.colors; - colors.highlightedColor = new Color(0.882f, 0.882f, 0.882f); - colors.pressedColor = new Color(0.698f, 0.698f, 0.698f); - colors.disabledColor = new Color(0.521f, 0.521f, 0.521f); - } - - private static void GetPrivateMethodByReflection() - { - if (PlaceUIElementRoot == null) - { - Assembly uiEditorAssembly = AppDomain.CurrentDomain.GetAssemblies() - .FirstOrDefault(asm => asm.GetName().Name == "UnityEditor.UI"); - if (uiEditorAssembly != null) - { - Type menuOptionType = uiEditorAssembly.GetType("UnityEditor.UI.MenuOptions"); - if (menuOptionType != null) - { - MethodInfo miPlaceUIElementRoot = menuOptionType.GetMethod( - "PlaceUIElementRoot", - BindingFlags.NonPublic | BindingFlags.Static); - if (miPlaceUIElementRoot != null) - { - PlaceUIElementRoot = Delegate.CreateDelegate( - typeof(Action), - miPlaceUIElementRoot) - as Action; - } - } - } - } - } - } -} diff --git a/Forest/Assets/PhxhSDK/Editor/ScrollView/PhxhScrollViewEditor.cs.meta b/Forest/Assets/PhxhSDK/Editor/ScrollView/PhxhScrollViewEditor.cs.meta deleted file mode 100644 index 125f37a..0000000 --- a/Forest/Assets/PhxhSDK/Editor/ScrollView/PhxhScrollViewEditor.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e29cfb1f37b2946bab6e55856dc160cc -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/ScrollView/PhxhScrollViewExEditor.cs b/Forest/Assets/PhxhSDK/Editor/ScrollView/PhxhScrollViewExEditor.cs deleted file mode 100644 index c570144..0000000 --- a/Forest/Assets/PhxhSDK/Editor/ScrollView/PhxhScrollViewExEditor.cs +++ /dev/null @@ -1,36 +0,0 @@ -// ----------------------------------------------------------------------- -// -// Copyright (c) AillieoTech. All rights reserved. -// -// ----------------------------------------------------------------------- - - - -namespace PhxhSDK -{ - using UnityEditor; - - [CustomEditor(typeof(PhxhScrollViewEx))] - public class PhxhScrollViewExEditor : PhxhScrollViewEditor - { - private SerializedProperty pageSize; - - protected override void OnEnable() - { - base.OnEnable(); - this.pageSize = this.serializedObject.FindProperty("pageSize"); - } - - protected override void DrawConfigInfo() - { - base.DrawConfigInfo(); - EditorGUILayout.PropertyField(this.pageSize); - } - - [MenuItem("GameObject/UI/DynamicScrollViewEx", false, 90)] - private static void AddScrollViewEx(MenuCommand menuCommand) - { - InternalAddScrollView(menuCommand); - } - } -} diff --git a/Forest/Assets/PhxhSDK/Editor/ScrollView/PhxhScrollViewExEditor.cs.meta b/Forest/Assets/PhxhSDK/Editor/ScrollView/PhxhScrollViewExEditor.cs.meta deleted file mode 100644 index ad18cee..0000000 --- a/Forest/Assets/PhxhSDK/Editor/ScrollView/PhxhScrollViewExEditor.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8712942f108f8440f8c2e28a682b7982 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/Shader.meta b/Forest/Assets/PhxhSDK/Editor/Shader.meta deleted file mode 100644 index 955de17..0000000 --- a/Forest/Assets/PhxhSDK/Editor/Shader.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 0c55fda8e51049cca056a7dfd6679b67 -timeCreated: 1703659156 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/Shader/AutoSetAllGpuInst.cs b/Forest/Assets/PhxhSDK/Editor/Shader/AutoSetAllGpuInst.cs deleted file mode 100644 index 4c01d8a..0000000 --- a/Forest/Assets/PhxhSDK/Editor/Shader/AutoSetAllGpuInst.cs +++ /dev/null @@ -1,34 +0,0 @@ -using UnityEditor; -using UnityEngine; - -namespace Tools.Shader -{ - public class AutoSetAllGpuInst - { - - [MenuItem("Tools/Shader/自动勾选所有材质的GPU Instancing")] - public static void AutoSet() - { - var guids = AssetDatabase.FindAssets("t:Material"); - foreach (var guid in guids) - { - var path = AssetDatabase.GUIDToAssetPath(guid); - var mat = AssetDatabase.LoadAssetAtPath(path); - if (mat == null) - { - continue; - } - if (!mat.enableInstancing) - { - mat.enableInstancing = true; - // 标记为dirty - EditorUtility.SetDirty(mat); - } - - } - AssetDatabase.SaveAssets(); - AssetDatabase.Refresh(); - } - - } -} diff --git a/Forest/Assets/PhxhSDK/Editor/Shader/AutoSetAllGpuInst.cs.meta b/Forest/Assets/PhxhSDK/Editor/Shader/AutoSetAllGpuInst.cs.meta deleted file mode 100644 index 422a5eb..0000000 --- a/Forest/Assets/PhxhSDK/Editor/Shader/AutoSetAllGpuInst.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: f10125d4d5aa438da943bf99569ae02a -timeCreated: 1703659172 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/VersionControlSystem.cs b/Forest/Assets/PhxhSDK/Editor/VersionControlSystem.cs deleted file mode 100644 index b997f9d..0000000 --- a/Forest/Assets/PhxhSDK/Editor/VersionControlSystem.cs +++ /dev/null @@ -1,179 +0,0 @@ -// using UnityEditor.VersionControl; -// using UnityEditor; -// using System.IO; -// using UnityEngine; -// -// public class VersionControlSystem -// { -// public static void Add(string path) -// { -// //if (!File.Exists(path)) -// //{ -// // Debug.LogError(" Failed to Add , File does not exist: " + path); -// // return; -// //} -// //if (Provider.onlineState != OnlineState.Online ) -// //{ -// // Debug.LogError($"PerfoceState :{Provider.onlineState}, Failed to connect to Perforce server."); -// // return; -// //} -// //AssetList assets = new AssetList(); -// //assets.Add(Provider.GetAssetByPath(path)); -// //Task t = Provider.Add(assets, recursive: false); -// //t.Wait(); -// -// //if (!t.success) -// //{ -// // Debug.LogError($"Failed to add file. "); -// // return; -// //} -// //AssetDatabase.Refresh(); -// } -// -// public static void Delete(string path) -// { -// //if (!File.Exists(path)) -// //{ -// // Debug.LogError(" Failed to Delete , File does not exist: " + path); -// // return; -// //} -// -// //if (Provider.onlineState != OnlineState.Online) -// //{ -// // Debug.LogError($"PerfoceState :{Provider.onlineState}, Failed to connect to Perforce server."); -// // return; -// //} -// //AssetList assets = new AssetList(); -// //assets.Add(Provider.GetAssetByPath(path)); -// //assets.Add(Provider.GetAssetByPath(path + ".meta")); -// //Task t = Provider.Delete(assets); -// //t.Wait(); -// -// //if (!t.success) -// //{ -// // Debug.LogError($"Failed to delete file: {t.text}"); -// // return; -// //} -// //AssetDatabase.Refresh(); -// } -// -// public static void Checkout(string path) -// { -// //if (Provider.onlineState != OnlineState.Online) -// //{ -// // Debug.LogError($"PerfoceState :{Provider.onlineState}, Failed to connect to Perforce server."); -// // return; -// //} -// //AssetList assets = new AssetList(); -// //var asset = Provider.GetAssetByPath(path); -// //if (asset != null) -// //{ -// // assets.Add(asset); -// //} -// -// //Task t; -// //if (assets.Count > 0) -// //{ -// // t = Provider.Checkout(assets, CheckoutMode.Both); -// // t.Wait(); -// //} -// //else -// //{ -// // t = Provider.Checkout(path, CheckoutMode.Both); -// // t.Wait(); -// //} -// -// //if (!t.success) -// //{ -// // Debug.LogError($"Failed to checkout file, Try again."); -// // return; -// //} -// //AssetDatabase.Refresh(); -// } -// -// public static void Revert(string path, RevertMode revertMode = RevertMode.Normal) -// { -// //if (Provider.onlineState != OnlineState.Online) -// //{ -// // Debug.LogError($"PerfoceState :{Provider.onlineState}, Failed to connect to Perforce server."); -// // return; -// //} -// //AssetList assets = new AssetList(); -// //var asset = Provider.GetAssetByPath(path); -// //if (asset != null) -// //{ -// // assets.Add(asset); -// //} -// -// //if (assets.Count > 0) -// //{ -// // Task t = Provider.Revert(assets, revertMode); -// // t.Wait(); -// // if (!t.success) -// // { -// // Debug.LogError($"Failed to revert file: {path}"); -// // return; -// // } -// //} -// //else -// //{ -// // Debug.LogError($"revert cannot find asset : {path}"); -// // return; -// //} -// //AssetDatabase.Refresh(); -// } -// -// public static void Submit(string path, string des) -// { -// //if (Provider.onlineState != OnlineState.Online) -// //{ -// // Debug.LogError($"PerfoceState :{Provider.onlineState}, Failed to connect to Perforce server."); -// // return; -// //} -// //AssetList assets = new AssetList(); -// //assets.Add(Provider.GetAssetByPath(path)); -// //Task t = Provider.Submit(new ChangeSet(), assets, des, saveOnly: false); -// //t.Wait(); -// -// //if (!t.success) -// //{ -// // Debug.LogError($"Failed to submit file"); -// // return; -// //} -// //AssetDatabase.Refresh(); -// } -// -// -// public static void GetLast() -// { -// //if (Provider.onlineState != OnlineState.Online) -// //{ -// // Debug.LogError($"PerfoceState :{Provider.onlineState}, Failed to connect to Perforce server."); -// // return; -// //} -// -// //string assetsFolderPath = "Assets"; -// -// //Asset asset = Provider.GetAssetByPath(assetsFolderPath); -// //if (asset == null) -// //{ -// // Debug.LogError("Failed to get Asset object for the 'Assets' folder."); -// // return; -// //} -// -// //Task t = Provider.GetLatest(asset); -// //t.Wait(); -// -// //if (t.success) -// //{ -// // DebugUtil.Log("Successfully pulled latest code and assets."); -// //} -// //else -// //{ -// // DebugUtil.LogError("Failed to pull latest code and assets."); -// //} -// -// //AssetDatabase.Refresh(); -// } -// } - diff --git a/Forest/Assets/PhxhSDK/Editor/VersionControlSystem.cs.meta b/Forest/Assets/PhxhSDK/Editor/VersionControlSystem.cs.meta deleted file mode 100644 index 9768324..0000000 --- a/Forest/Assets/PhxhSDK/Editor/VersionControlSystem.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1f387d1d09e30f7449ea6245cc4f1665 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/YooAsset.meta b/Forest/Assets/PhxhSDK/Editor/YooAsset.meta deleted file mode 100644 index 1ae5015..0000000 --- a/Forest/Assets/PhxhSDK/Editor/YooAsset.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 8661f74ebac149638250375c88d0e8ac -timeCreated: 1708587366 \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/YooAsset/CustomPackRule.cs b/Forest/Assets/PhxhSDK/Editor/YooAsset/CustomPackRule.cs deleted file mode 100644 index dc3c5a8..0000000 --- a/Forest/Assets/PhxhSDK/Editor/YooAsset/CustomPackRule.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.IO; -using UnityEngine; -using YooAsset.Editor; - -[DisplayName("打包特效纹理(自定义)")] -public class PackEffectTexture : IPackRule -{ - private const string PackDirectory = "Assets/Effect/Textures/"; - - PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data) - { - string assetPath = data.AssetPath; - if (assetPath.StartsWith(PackDirectory) == false) - throw new Exception($"Only support folder : {PackDirectory}"); - - string assetName = Path.GetFileName(assetPath).ToLower(); - string firstChar = assetName.Substring(0, 1); - string bundleName = $"{PackDirectory}effect_texture_{firstChar}"; - var packRuleResult = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension); - return packRuleResult; - } -} - -[DisplayName("打包视频(自定义)")] -public class PackVideo : IPackRule -{ - public PackRuleResult GetPackRuleResult(PackRuleData data) - { - string bundleName = RemoveExtension(data.AssetPath); - string fileExtension = Path.GetExtension(data.AssetPath); - fileExtension = fileExtension.Remove(0, 1); - PackRuleResult result = new PackRuleResult(bundleName, fileExtension); - return result; - } - - private string RemoveExtension(string str) - { - if (string.IsNullOrEmpty(str)) - return str; - - int index = str.LastIndexOf("."); - if (index == -1) - return str; - else - return str.Remove(index); //"assets/config/test.unity3d" --> "assets/config/test" - } -} \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/YooAsset/CustomPackRule.cs.meta b/Forest/Assets/PhxhSDK/Editor/YooAsset/CustomPackRule.cs.meta deleted file mode 100644 index d4d835c..0000000 --- a/Forest/Assets/PhxhSDK/Editor/YooAsset/CustomPackRule.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5af4f68262c016040a685954cc8f2e86 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/YooAsset/PackageComparator.meta b/Forest/Assets/PhxhSDK/Editor/YooAsset/PackageComparator.meta deleted file mode 100644 index 71fbd8e..0000000 --- a/Forest/Assets/PhxhSDK/Editor/YooAsset/PackageComparator.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 9a960a9aab326ed4f9a31bda4e99ec87 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/YooAsset/PackageComparator/PackageComparatorWindow.cs b/Forest/Assets/PhxhSDK/Editor/YooAsset/PackageComparator/PackageComparatorWindow.cs deleted file mode 100644 index d3b6728..0000000 --- a/Forest/Assets/PhxhSDK/Editor/YooAsset/PackageComparator/PackageComparatorWindow.cs +++ /dev/null @@ -1,138 +0,0 @@ -using System.IO; -using System.Collections.Generic; -using System.Linq; -using UnityEngine; -using UnityEditor; - -namespace YooAsset.Editor -{ - public class PackageComparatorWindow : EditorWindow - { - static PackageComparatorWindow _thisInstance; - - [MenuItem("Tools/补丁包比对工具", false, 102)] - static void ShowWindow() - { - if (_thisInstance == null) - { - _thisInstance = EditorWindow.GetWindow(typeof(PackageComparatorWindow), false, "补丁包比对工具", true) as PackageComparatorWindow; - _thisInstance.minSize = new Vector2(800, 600); - } - _thisInstance.Show(); - } - - private string _manifestPath1 = string.Empty; - private string _manifestPath2 = string.Empty; - private readonly List _changeList = new List(); - private readonly List _newList = new List(); - private Vector2 _scrollPos1; - private Vector2 _scrollPos2; - - private void OnGUI() - { - GUILayout.Space(10); - EditorGUILayout.BeginHorizontal(); - if (GUILayout.Button("选择补丁包1", GUILayout.MaxWidth(150))) - { - string resultPath = EditorUtility.OpenFilePanel("Find", "Assets/", "bytes"); - if (string.IsNullOrEmpty(resultPath)) - return; - _manifestPath1 = resultPath; - } - EditorGUILayout.LabelField(_manifestPath1); - EditorGUILayout.EndHorizontal(); - - GUILayout.Space(10); - EditorGUILayout.BeginHorizontal(); - if (GUILayout.Button("选择补丁包2", GUILayout.MaxWidth(150))) - { - string resultPath = EditorUtility.OpenFilePanel("Find", "Assets/", "bytes"); - if (string.IsNullOrEmpty(resultPath)) - return; - _manifestPath2 = resultPath; - } - EditorGUILayout.LabelField(_manifestPath2); - EditorGUILayout.EndHorizontal(); - - if (string.IsNullOrEmpty(_manifestPath1) == false && string.IsNullOrEmpty(_manifestPath2) == false) - { - if (GUILayout.Button("比对差异", GUILayout.MaxWidth(150))) - { - ComparePackage(_changeList, _newList); - } - } - - EditorGUILayout.Space(); - using (new EditorGUI.DisabledScope(false)) - { - int totalCount = _changeList.Count; - EditorGUILayout.Foldout(true, $"差异列表 ( {totalCount} )"); - - EditorGUI.indentLevel = 1; - _scrollPos1 = EditorGUILayout.BeginScrollView(_scrollPos1); - { - foreach (var bundle in _changeList) - { - EditorGUILayout.LabelField($"{bundle.BundleName} | {(bundle.FileSize / 1024)}K"); - } - } - EditorGUILayout.EndScrollView(); - EditorGUI.indentLevel = 0; - } - - EditorGUILayout.Space(); - using (new EditorGUI.DisabledScope(false)) - { - int totalCount = _newList.Count; - EditorGUILayout.Foldout(true, $"新增列表 ( {totalCount} )"); - - EditorGUI.indentLevel = 1; - _scrollPos2 = EditorGUILayout.BeginScrollView(_scrollPos2); - { - foreach (var bundle in _newList) - { - EditorGUILayout.LabelField($"{bundle.BundleName}"); - } - } - EditorGUILayout.EndScrollView(); - EditorGUI.indentLevel = 0; - } - } - - private void ComparePackage(List changeList, List newList) - { - changeList.Clear(); - newList.Clear(); - - // 加载补丁清单1 - byte[] bytesData1 = FileUtility.ReadAllBytes(_manifestPath1); - PackageManifest manifest1 = ManifestTools.DeserializeFromBinary(bytesData1); - - // 加载补丁清单1 - byte[] bytesData2 = FileUtility.ReadAllBytes(_manifestPath2); - PackageManifest manifest2 = ManifestTools.DeserializeFromBinary(bytesData2); - - // 拷贝文件列表 - foreach (var bundle2 in manifest2.BundleList) - { - if (manifest1.TryGetPackageBundleByBundleName(bundle2.BundleName, out PackageBundle bundle1)) - { - if (bundle2.FileHash != bundle1.FileHash) - { - changeList.Add(bundle2); - } - } - else - { - newList.Add(bundle2); - } - } - - // 按字母重新排序 - changeList.Sort((x, y) => string.Compare(x.BundleName, y.BundleName)); - newList.Sort((x, y) => string.Compare(x.BundleName, y.BundleName)); - - Debug.Log("资源包差异比对完成!"); - } - } -} diff --git a/Forest/Assets/PhxhSDK/Editor/YooAsset/PackageComparator/PackageComparatorWindow.cs.meta b/Forest/Assets/PhxhSDK/Editor/YooAsset/PackageComparator/PackageComparatorWindow.cs.meta deleted file mode 100644 index efc87bd..0000000 --- a/Forest/Assets/PhxhSDK/Editor/YooAsset/PackageComparator/PackageComparatorWindow.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6ff3c700b7f108b48998aa1630a769e1 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/YooAsset/PackageImporter.meta b/Forest/Assets/PhxhSDK/Editor/YooAsset/PackageImporter.meta deleted file mode 100644 index 01ea4d3..0000000 --- a/Forest/Assets/PhxhSDK/Editor/YooAsset/PackageImporter.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 90c222b00589b544c955a4a047a92cf9 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/YooAsset/PackageImporter/PackageImporterWindow.cs b/Forest/Assets/PhxhSDK/Editor/YooAsset/PackageImporter/PackageImporterWindow.cs deleted file mode 100644 index 690a7f8..0000000 --- a/Forest/Assets/PhxhSDK/Editor/YooAsset/PackageImporter/PackageImporterWindow.cs +++ /dev/null @@ -1,91 +0,0 @@ -using System.IO; -using UnityEngine; -using UnityEditor; - -namespace YooAsset.Editor -{ - public class PackageImporterWindow : EditorWindow - { - static PackageImporterWindow _thisInstance; - - [MenuItem("Tools/补丁包导入工具", false, 101)] - static void ShowWindow() - { - if (_thisInstance == null) - { - _thisInstance = EditorWindow.GetWindow(typeof(PackageImporterWindow), false, "补丁包导入工具", true) as PackageImporterWindow; - _thisInstance.minSize = new Vector2(800, 600); - } - _thisInstance.Show(); - } - - private string _manifestPath = string.Empty; - private string _packageName = "DefaultPackage"; - - private void OnGUI() - { - GUILayout.Space(10); - EditorGUILayout.BeginHorizontal(); - if (GUILayout.Button("选择补丁包", GUILayout.MaxWidth(150))) - { - string resultPath = EditorUtility.OpenFilePanel("Find", "Assets/", "bytes"); - if (string.IsNullOrEmpty(resultPath)) - return; - _manifestPath = resultPath; - } - EditorGUILayout.LabelField(_manifestPath); - EditorGUILayout.EndHorizontal(); - - if (string.IsNullOrEmpty(_manifestPath) == false) - { - if (GUILayout.Button("导入补丁包(全部文件)", GUILayout.MaxWidth(150))) - { - string streamingAssetsRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot(); - EditorTools.ClearFolder(streamingAssetsRoot); - CopyPackageFiles(_manifestPath); - } - } - } - - private void CopyPackageFiles(string manifestFilePath) - { - string manifestFileName = Path.GetFileNameWithoutExtension(manifestFilePath); - string outputDirectory = Path.GetDirectoryName(manifestFilePath); - - // 加载补丁清单 - byte[] bytesData = FileUtility.ReadAllBytes(manifestFilePath); - PackageManifest manifest = ManifestTools.DeserializeFromBinary(bytesData); - - // 拷贝核心文件 - { - string sourcePath = $"{outputDirectory}/{manifestFileName}.bytes"; - string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsRoot()}/{_packageName}/{manifestFileName}.bytes"; - EditorTools.CopyFile(sourcePath, destPath, true); - } - { - string sourcePath = $"{outputDirectory}/{manifestFileName}.hash"; - string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsRoot()}/{_packageName}/{manifestFileName}.hash"; - EditorTools.CopyFile(sourcePath, destPath, true); - } - { - string fileName = YooAssetSettingsData.GetPackageVersionFileName(manifest.PackageName); - string sourcePath = $"{outputDirectory}/{fileName}"; - string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsRoot()}/{_packageName}/{fileName}"; - EditorTools.CopyFile(sourcePath, destPath, true); - } - - // 拷贝文件列表 - int fileCount = 0; - foreach (var packageBundle in manifest.BundleList) - { - fileCount++; - string sourcePath = $"{outputDirectory}/{packageBundle.FileName}"; - string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsRoot()}/{_packageName}/{packageBundle.FileName}"; - EditorTools.CopyFile(sourcePath, destPath, true); - } - - Debug.Log($"补丁包拷贝完成,一共拷贝了{fileCount}个资源文件"); - AssetDatabase.Refresh(); - } - } -} \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/YooAsset/PackageImporter/PackageImporterWindow.cs.meta b/Forest/Assets/PhxhSDK/Editor/YooAsset/PackageImporter/PackageImporterWindow.cs.meta deleted file mode 100644 index cb3d485..0000000 --- a/Forest/Assets/PhxhSDK/Editor/YooAsset/PackageImporter/PackageImporterWindow.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 699068f8f637708409436199baa62c1f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/YooAsset/ShaderVariantCollector.meta b/Forest/Assets/PhxhSDK/Editor/YooAsset/ShaderVariantCollector.meta deleted file mode 100644 index 99eca09..0000000 --- a/Forest/Assets/PhxhSDK/Editor/YooAsset/ShaderVariantCollector.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 6ac3c3466d3611a479a13f79a5be15c6 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/YooAsset/ShaderVariantCollector/ShaderVariantCollectionHelper.cs b/Forest/Assets/PhxhSDK/Editor/YooAsset/ShaderVariantCollector/ShaderVariantCollectionHelper.cs deleted file mode 100644 index 7345fbf..0000000 --- a/Forest/Assets/PhxhSDK/Editor/YooAsset/ShaderVariantCollector/ShaderVariantCollectionHelper.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; -using UnityEngine; -using UnityEngine.Rendering; -using UnityEditor; -using YooAsset.Editor; - -public static class ShaderVariantCollectionHelper -{ - public static void ClearCurrentShaderVariantCollection() - { - EditorTools.InvokeNonPublicStaticMethod(typeof(ShaderUtil), "ClearCurrentShaderVariantCollection"); - } - public static void SaveCurrentShaderVariantCollection(string savePath) - { - EditorTools.InvokeNonPublicStaticMethod(typeof(ShaderUtil), "SaveCurrentShaderVariantCollection", savePath); - } - public static int GetCurrentShaderVariantCollectionShaderCount() - { - return (int)EditorTools.InvokeNonPublicStaticMethod(typeof(ShaderUtil), "GetCurrentShaderVariantCollectionShaderCount"); - } - public static int GetCurrentShaderVariantCollectionVariantCount() - { - return (int)EditorTools.InvokeNonPublicStaticMethod(typeof(ShaderUtil), "GetCurrentShaderVariantCollectionVariantCount"); - } - - /// - /// 获取着色器的变种总数量 - /// - public static string GetShaderVariantCount(string assetPath) - { - Shader shader = AssetDatabase.LoadAssetAtPath(assetPath); - var variantCount = EditorTools.InvokeNonPublicStaticMethod(typeof(ShaderUtil), "GetVariantCount", shader, true); - return variantCount.ToString(); - } -} \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/YooAsset/ShaderVariantCollector/ShaderVariantCollectionHelper.cs.meta b/Forest/Assets/PhxhSDK/Editor/YooAsset/ShaderVariantCollector/ShaderVariantCollectionHelper.cs.meta deleted file mode 100644 index 301e681..0000000 --- a/Forest/Assets/PhxhSDK/Editor/YooAsset/ShaderVariantCollector/ShaderVariantCollectionHelper.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ab74d4ff4a2805147883de70a1559a0a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/YooAsset/ShaderVariantCollector/ShaderVariantCollectionManifest.cs b/Forest/Assets/PhxhSDK/Editor/YooAsset/ShaderVariantCollector/ShaderVariantCollectionManifest.cs deleted file mode 100644 index 73f7b78..0000000 --- a/Forest/Assets/PhxhSDK/Editor/YooAsset/ShaderVariantCollector/ShaderVariantCollectionManifest.cs +++ /dev/null @@ -1,146 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using UnityEngine; -using UnityEngine.Rendering; -using UnityEditor; - -[Serializable] -public class ShaderVariantCollectionManifest -{ - [Serializable] - public class ShaderVariantElement - { - /// - /// Pass type to use in this variant. - /// - public PassType PassType; - - /// - /// Array of shader keywords to use in this variant. - /// - public string[] Keywords; - } - - [Serializable] - public class ShaderVariantInfo - { - /// - /// 着色器资源路径. - /// - public string AssetPath; - - /// - /// 着色器名称 - /// - public string ShaderName; - - /// - /// 着色器变种总数 - /// - public int ShaderVariantCount = 0; - - /// - /// 着色器变种列表 - /// - public List ShaderVariantElements = new List(1000); - } - - - /// - /// Number of shaders in this collection - /// - public int ShaderTotalCount; - - /// - /// Number of total varians in this collection - /// - public int VariantTotalCount; - - /// - /// Shader variants info list. - /// - public List ShaderVariantInfos = new List(1000); - - /// - /// 添加着色器变种信息 - /// - public void AddShaderVariant(string assetPath, string shaderName, PassType passType, string[] keywords) - { - var info = GetOrCreateShaderVariantInfo(assetPath, shaderName); - ShaderVariantElement element = new ShaderVariantElement(); - element.PassType = passType; - element.Keywords = keywords; - info.ShaderVariantElements.Add(element); - info.ShaderVariantCount++; - } - private ShaderVariantInfo GetOrCreateShaderVariantInfo(string assetPath, string shaderName) - { - var selectList = ShaderVariantInfos.Where(t => t.ShaderName == shaderName && t.AssetPath == assetPath).ToList(); - if (selectList.Count == 0) - { - ShaderVariantInfo newInfo = new ShaderVariantInfo(); - newInfo.AssetPath = assetPath; - newInfo.ShaderName = shaderName; - ShaderVariantInfos.Add(newInfo); - return newInfo; - } - - if (selectList.Count != 1) - throw new Exception("Should never get here !"); - - return selectList[0]; - } - - - /// - /// 解析SVC文件并将数据写入到清单 - /// - public static ShaderVariantCollectionManifest Extract(ShaderVariantCollection svc) - { - var manifest = new ShaderVariantCollectionManifest(); - manifest.ShaderTotalCount = ShaderVariantCollectionHelper.GetCurrentShaderVariantCollectionShaderCount(); - manifest.VariantTotalCount = ShaderVariantCollectionHelper.GetCurrentShaderVariantCollectionVariantCount(); - - using (var so = new SerializedObject(svc)) - { - var shaderArray = so.FindProperty("m_Shaders.Array"); - if (shaderArray != null && shaderArray.isArray) - { - for (int i = 0; i < shaderArray.arraySize; ++i) - { - var shaderRef = shaderArray.FindPropertyRelative($"data[{i}].first"); - var shaderVariantsArray = shaderArray.FindPropertyRelative($"data[{i}].second.variants"); - if (shaderRef != null && shaderRef.propertyType == SerializedPropertyType.ObjectReference && shaderVariantsArray != null && shaderVariantsArray.isArray) - { - var shader = shaderRef.objectReferenceValue as Shader; - if (shader == null) - { - throw new Exception("Invalid shader in ShaderVariantCollection file."); - } - - string shaderAssetPath = AssetDatabase.GetAssetPath(shader); - string shaderName = shader.name; - - // 添加变种信息 - for (int j = 0; j < shaderVariantsArray.arraySize; ++j) - { - var propKeywords = shaderVariantsArray.FindPropertyRelative($"Array.data[{j}].keywords"); - var propPassType = shaderVariantsArray.FindPropertyRelative($"Array.data[{j}].passType"); - if (propKeywords != null && propPassType != null && propKeywords.propertyType == SerializedPropertyType.String) - { - string[] keywords = propKeywords.stringValue.Split(' '); - PassType pathType = (PassType)propPassType.intValue; - manifest.AddShaderVariant(shaderAssetPath, shaderName, pathType, keywords); - } - } - } - } - } - } - - return manifest; - } -} \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/YooAsset/ShaderVariantCollector/ShaderVariantCollectionManifest.cs.meta b/Forest/Assets/PhxhSDK/Editor/YooAsset/ShaderVariantCollector/ShaderVariantCollectionManifest.cs.meta deleted file mode 100644 index 1ccf9c8..0000000 --- a/Forest/Assets/PhxhSDK/Editor/YooAsset/ShaderVariantCollector/ShaderVariantCollectionManifest.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 97098b04691f5c046ac4829f1d72f425 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/YooAsset/ShaderVariantCollector/ShaderVariantCollector.cs b/Forest/Assets/PhxhSDK/Editor/YooAsset/ShaderVariantCollector/ShaderVariantCollector.cs deleted file mode 100644 index 5a95367..0000000 --- a/Forest/Assets/PhxhSDK/Editor/YooAsset/ShaderVariantCollector/ShaderVariantCollector.cs +++ /dev/null @@ -1,256 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.IO; -using UnityEngine; -using UnityEditor; -using UnityEditor.SceneManagement; -using YooAsset.Editor; -using Debug = UnityEngine.Debug; - -public static class ShaderVariantCollector -{ - private enum ESteps - { - None, - Prepare, - CollectAllMaterial, - CollectVariants, - CollectSleeping, - WaitingDone, - } - - private const float WaitMilliseconds = 1000f; - private const float SleepMilliseconds = 100f; - private static string _savePath; - private static string _packageName; - private static int _processMaxNum; - private static Action _completedCallback; - - private static ESteps _steps = ESteps.None; - private static Stopwatch _elapsedTime; - private static List _allMaterials; - private static List _allSpheres = new List(1000); - - - /// - /// 开始收集 - /// - public static void Run(string savePath, string packageName, int processMaxNum, Action completedCallback) - { - if (_steps != ESteps.None) - return; - - if (Path.HasExtension(savePath) == false) - savePath = $"{savePath}.shadervariants"; - if (Path.GetExtension(savePath) != ".shadervariants") - throw new System.Exception("Shader variant file extension is invalid."); - if (string.IsNullOrEmpty(packageName)) - throw new System.Exception("Package name is null or empty !"); - - // 注意:先删除再保存,否则ShaderVariantCollection内容将无法及时刷新 - AssetDatabase.DeleteAsset(savePath); - EditorTools.CreateFileDirectory(savePath); - _savePath = savePath; - _packageName = packageName; - _processMaxNum = processMaxNum; - _completedCallback = completedCallback; - - // 聚焦到游戏窗口 - EditorTools.FocusUnityGameWindow(); - - // 创建临时测试场景 - CreateTempScene(); - - _steps = ESteps.Prepare; - EditorApplication.update += EditorUpdate; - } - - private static void EditorUpdate() - { - if (_steps == ESteps.None) - return; - - if (_steps == ESteps.Prepare) - { - ShaderVariantCollectionHelper.ClearCurrentShaderVariantCollection(); - _steps = ESteps.CollectAllMaterial; - return; //等待一帧 - } - - if (_steps == ESteps.CollectAllMaterial) - { - _allMaterials = GetAllMaterials(); - _steps = ESteps.CollectVariants; - return; //等待一帧 - } - - if (_steps == ESteps.CollectVariants) - { - int count = Mathf.Min(_processMaxNum, _allMaterials.Count); - List range = _allMaterials.GetRange(0, count); - _allMaterials.RemoveRange(0, count); - CollectVariants(range); - - if (_allMaterials.Count > 0) - { - _elapsedTime = Stopwatch.StartNew(); - _steps = ESteps.CollectSleeping; - } - else - { - _elapsedTime = Stopwatch.StartNew(); - _steps = ESteps.WaitingDone; - } - } - - if (_steps == ESteps.CollectSleeping) - { - if (_elapsedTime.ElapsedMilliseconds > SleepMilliseconds) - { - DestroyAllSpheres(); - _elapsedTime.Stop(); - _steps = ESteps.CollectVariants; - } - } - - if (_steps == ESteps.WaitingDone) - { - // 注意:一定要延迟保存才会起效 - if (_elapsedTime.ElapsedMilliseconds > WaitMilliseconds) - { - _elapsedTime.Stop(); - _steps = ESteps.None; - - // 保存结果并创建清单 - ShaderVariantCollectionHelper.SaveCurrentShaderVariantCollection(_savePath); - CreateManifest(); - - Debug.Log($"搜集SVC完毕!"); - EditorApplication.update -= EditorUpdate; - _completedCallback?.Invoke(); - } - } - } - private static void CreateTempScene() - { - EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects); - } - private static List GetAllMaterials() - { - int progressValue = 0; - List allAssets = new List(1000); - - // 获取所有打包的资源 - CollectResult collectResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(EBuildMode.DryRunBuild, _packageName); - foreach (var assetInfo in collectResult.CollectAssets) - { - string[] depends = AssetDatabase.GetDependencies(assetInfo.AssetInfo.AssetPath, true); - foreach (var dependAsset in depends) - { - if (allAssets.Contains(dependAsset) == false) - allAssets.Add(dependAsset); - } - EditorTools.DisplayProgressBar("获取所有打包资源", ++progressValue, collectResult.CollectAssets.Count); - } - EditorTools.ClearProgressBar(); - - // 搜集所有材质球 - progressValue = 0; - List allMaterial = new List(1000); - foreach (var assetPath in allAssets) - { - System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath); - if (assetType == typeof(UnityEngine.Material)) - { - allMaterial.Add(assetPath); - } - EditorTools.DisplayProgressBar("搜集所有材质球", ++progressValue, allAssets.Count); - } - EditorTools.ClearProgressBar(); - - // 返回结果 - return allMaterial; - } - private static void CollectVariants(List materials) - { - Camera camera = Camera.main; - if (camera == null) - throw new System.Exception("Not found main camera."); - - // 设置主相机 - float aspect = camera.aspect; - int totalMaterials = materials.Count; - float height = Mathf.Sqrt(totalMaterials / aspect) + 1; - float width = Mathf.Sqrt(totalMaterials / aspect) * aspect + 1; - float halfHeight = Mathf.CeilToInt(height / 2f); - float halfWidth = Mathf.CeilToInt(width / 2f); - camera.orthographic = true; - camera.orthographicSize = halfHeight; - camera.transform.position = new Vector3(0f, 0f, -10f); - - // 创建测试球体 - int xMax = (int)(width - 1); - int x = 0, y = 0; - int progressValue = 0; - for (int i = 0; i < materials.Count; i++) - { - var material = materials[i]; - var position = new Vector3(x - halfWidth + 1f, y - halfHeight + 1f, 0f); - var go = CreateSphere(material, position, i); - if (go != null) - _allSpheres.Add(go); - if (x == xMax) - { - x = 0; - y++; - } - else - { - x++; - } - EditorTools.DisplayProgressBar("照射所有材质球", ++progressValue, materials.Count); - } - EditorTools.ClearProgressBar(); - } - private static GameObject CreateSphere(string assetPath, Vector3 position, int index) - { - var material = AssetDatabase.LoadAssetAtPath(assetPath); - var shader = material.shader; - if (shader == null) - return null; - - var go = GameObject.CreatePrimitive(PrimitiveType.Sphere); - go.GetComponent().sharedMaterial = material; - go.transform.position = position; - go.name = $"Sphere_{index} | {material.name}"; - return go; - } - private static void DestroyAllSpheres() - { - foreach (var go in _allSpheres) - { - GameObject.DestroyImmediate(go); - } - _allSpheres.Clear(); - - // 尝试释放编辑器加载的资源 - EditorUtility.UnloadUnusedAssetsImmediate(true); - } - private static void CreateManifest() - { - AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); - - ShaderVariantCollection svc = AssetDatabase.LoadAssetAtPath(_savePath); - if (svc != null) - { - var wrapper = ShaderVariantCollectionManifest.Extract(svc); - string jsonData = JsonUtility.ToJson(wrapper, true); - string savePath = _savePath.Replace(".shadervariants", ".json"); - File.WriteAllText(savePath, jsonData); - } - - AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); - } -} \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/YooAsset/ShaderVariantCollector/ShaderVariantCollector.cs.meta b/Forest/Assets/PhxhSDK/Editor/YooAsset/ShaderVariantCollector/ShaderVariantCollector.cs.meta deleted file mode 100644 index 79df03e..0000000 --- a/Forest/Assets/PhxhSDK/Editor/YooAsset/ShaderVariantCollector/ShaderVariantCollector.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 21b4cc6bf4c0c064d8e2687024e24c86 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/YooAsset/ShaderVariantCollector/ShaderVariantCollectorSetting.cs b/Forest/Assets/PhxhSDK/Editor/YooAsset/ShaderVariantCollector/ShaderVariantCollectorSetting.cs deleted file mode 100644 index 62fecc0..0000000 --- a/Forest/Assets/PhxhSDK/Editor/YooAsset/ShaderVariantCollector/ShaderVariantCollectorSetting.cs +++ /dev/null @@ -1,29 +0,0 @@ -using UnityEngine; -using UnityEditor; - -public class ShaderVariantCollectorSetting : ScriptableObject -{ - private const string DefaultSavePath = "Assets/MyShaderVariants.shadervariants"; - - public static string GeFileSavePath(string packageName) - { - string key = $"{Application.productName}_{packageName}_GeFileSavePath"; - return EditorPrefs.GetString(key, DefaultSavePath); - } - public static void SetFileSavePath(string packageName, string savePath) - { - string key = $"{Application.productName}_{packageName}_GeFileSavePath"; - EditorPrefs.SetString(key, savePath); - } - - public static int GeProcessCapacity(string packageName) - { - string key = $"{Application.productName}_{packageName}_GeProcessCapacity"; - return EditorPrefs.GetInt(key, 1000); - } - public static void SetProcessCapacity(string packageName, int capacity) - { - string key = $"{Application.productName}_{packageName}_GeProcessCapacity"; - EditorPrefs.SetInt(key, capacity); - } -} \ No newline at end of file diff --git a/Forest/Assets/PhxhSDK/Editor/YooAsset/ShaderVariantCollector/ShaderVariantCollectorSetting.cs.meta b/Forest/Assets/PhxhSDK/Editor/YooAsset/ShaderVariantCollector/ShaderVariantCollectorSetting.cs.meta deleted file mode 100644 index b9566a8..0000000 --- a/Forest/Assets/PhxhSDK/Editor/YooAsset/ShaderVariantCollector/ShaderVariantCollectorSetting.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 44454e58a49818040a1aef5799e71b30 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Forest/Assets/PhxhSDK/Editor/YooAsset/ShaderVariantCollector/ShaderVariantCollectorWindow.cs b/Forest/Assets/PhxhSDK/Editor/YooAsset/ShaderVariantCollector/ShaderVariantCollectorWindow.cs deleted file mode 100644 index 1120d61..0000000 --- a/Forest/Assets/PhxhSDK/Editor/YooAsset/ShaderVariantCollector/ShaderVariantCollectorWindow.cs +++ /dev/null @@ -1,150 +0,0 @@ -#if UNITY_2019_4_OR_NEWER -using System; -using System.Linq; -using System.Collections.Generic; -using UnityEditor; -using UnityEngine; -using UnityEditor.UIElements; -using UnityEngine.UIElements; -using YooAsset.Editor; - -public class ShaderVariantCollectorWindow : EditorWindow -{ - [MenuItem("Tools/着色器变种收集器", false, 100)] - public static void OpenWindow() - { - ShaderVariantCollectorWindow window = GetWindow("着色器变种收集工具", true); - window.minSize = new Vector2(800, 600); - } - - private Button _collectButton; - private TextField _collectOutputField; - private Label _currentShaderCountField; - private Label _currentVariantCountField; - private SliderInt _processCapacitySlider; - private PopupField _packageField; - - private List _packageNames; - private string _currentPackageName; - - public void CreateGUI() - { - try - { - VisualElement root = this.rootVisualElement; - - // 加载布局文件 - var visualAsset = UxmlLoader.LoadWindowUXML(); - if (visualAsset == null) - return; - - visualAsset.CloneTree(root); - - // 包裹名称列表 - _packageNames = GetBuildPackageNames(); - _currentPackageName = _packageNames[0]; - - // 文件输出目录 - _collectOutputField = root.Q("CollectOutput"); - _collectOutputField.SetValueWithoutNotify(ShaderVariantCollectorSetting.GeFileSavePath(_currentPackageName)); - _collectOutputField.RegisterValueChangedCallback(evt => - { - ShaderVariantCollectorSetting.SetFileSavePath(_currentPackageName, _collectOutputField.value); - }); - - // 收集的包裹 - var packageContainer = root.Q("PackageContainer"); - if (_packageNames.Count > 0) - { - int defaultIndex = GetDefaultPackageIndex(_currentPackageName); - _packageField = new PopupField(_packageNames, defaultIndex); - _packageField.label = "Package"; - _packageField.style.width = 350; - _packageField.RegisterValueChangedCallback(evt => - { - _currentPackageName = _packageField.value; - }); - packageContainer.Add(_packageField); - } - else - { - _packageField = new PopupField(); - _packageField.label = "Package"; - _packageField.style.width = 350; - packageContainer.Add(_packageField); - } - - // 容器值 - _processCapacitySlider = root.Q("ProcessCapacity"); - _processCapacitySlider.SetValueWithoutNotify(ShaderVariantCollectorSetting.GeProcessCapacity(_currentPackageName)); -#if !UNITY_2020_3_OR_NEWER - _processCapacitySlider.label = $"Capacity ({_processCapacitySlider.value})"; - _processCapacitySlider.RegisterValueChangedCallback(evt => - { - ShaderVariantCollectorSetting.SetProcessCapacity(_currentPackageName, _processCapacitySlider.value); - _processCapacitySlider.label = $"Capacity ({_processCapacitySlider.value})"; - }); -#else - _processCapacitySlider.RegisterValueChangedCallback(evt => - { - ShaderVariantCollectorSetting.SetProcessCapacity(_currentPackageName, _processCapacitySlider.value); - }); -#endif - - _currentShaderCountField = root.Q