From 6446b3ed400ced2da0517502ff68bdb4bc322ab9 Mon Sep 17 00:00:00 2001 From: hevinci Date: Mon, 18 Jul 2022 15:50:34 +0800 Subject: [PATCH] Update samples --- .../Scripts/Editor/CustomPackRule.cs | 25 +++++++++++++++++++ .../Scripts/Editor/CustomPackRule.cs.meta | 11 ++++++++ 2 files changed, 36 insertions(+) create mode 100644 Assets/Samples~/ExtensionSample/Scripts/Editor/CustomPackRule.cs create mode 100644 Assets/Samples~/ExtensionSample/Scripts/Editor/CustomPackRule.cs.meta diff --git a/Assets/Samples~/ExtensionSample/Scripts/Editor/CustomPackRule.cs b/Assets/Samples~/ExtensionSample/Scripts/Editor/CustomPackRule.cs new file mode 100644 index 0000000..3046c38 --- /dev/null +++ b/Assets/Samples~/ExtensionSample/Scripts/Editor/CustomPackRule.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using UnityEngine; +using YooAsset.Editor; + +/// +/// 按照文件名的首字母来划分资源 +/// +public class PackEffectTexture : IPackRule +{ + private const string PackDirectory = "Assets/Effect/Textures/"; + + string IPackRule.GetBundleName(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); + return $"{PackDirectory}effect_texture_{firstChar}"; + } +} \ No newline at end of file diff --git a/Assets/Samples~/ExtensionSample/Scripts/Editor/CustomPackRule.cs.meta b/Assets/Samples~/ExtensionSample/Scripts/Editor/CustomPackRule.cs.meta new file mode 100644 index 0000000..40f5ad7 --- /dev/null +++ b/Assets/Samples~/ExtensionSample/Scripts/Editor/CustomPackRule.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ff1eb84d9996ca1409e37f45617b1bdb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: