浏览代码

增加YooAsset的shader collect功能

大爷 2 年之前
父节点
当前提交
19313897c7
共有 36 个文件被更改,包括 1128 次插入6 次删除
  1. 2 2
      .gitignore
  2. 2 2
      Unity/Assets/AssetBundleCollectorSetting.asset
  3. 8 0
      Unity/Assets/Editor.meta
  4. 8 0
      Unity/Assets/Editor/Helper.meta
  5. 59 0
      Unity/Assets/Editor/Helper/EditorResHelper.cs
  6. 3 0
      Unity/Assets/Editor/Helper/EditorResHelper.cs.meta
  7. 129 0
      Unity/Assets/Editor/Helper/ShellHelper.cs
  8. 11 0
      Unity/Assets/Editor/Helper/ShellHelper.cs.meta
  9. 8 0
      Unity/Assets/Editor/YooAsset.meta
  10. 23 0
      Unity/Assets/Editor/YooAsset/AssetBundleCollectorConfig.xml
  11. 7 0
      Unity/Assets/Editor/YooAsset/AssetBundleCollectorConfig.xml.meta
  12. 8 0
      Unity/Assets/Editor/YooAsset/Encryption.meta
  13. 40 0
      Unity/Assets/Editor/YooAsset/Encryption/ProjectSEncryption.cs
  14. 11 0
      Unity/Assets/Editor/YooAsset/Encryption/ProjectSEncryption.cs.meta
  15. 3 0
      Unity/Assets/Editor/YooAsset/FilterRule.meta
  16. 16 0
      Unity/Assets/Editor/YooAsset/FilterRule/CollectShaderVariants.cs
  17. 3 0
      Unity/Assets/Editor/YooAsset/FilterRule/CollectShaderVariants.cs.meta
  18. 3 0
      Unity/Assets/Editor/YooAsset/PackRule.meta
  19. 18 0
      Unity/Assets/Editor/YooAsset/PackRule/PackShaderVariants.cs
  20. 3 0
      Unity/Assets/Editor/YooAsset/PackRule/PackShaderVariants.cs.meta
  21. 3 0
      Unity/Assets/Editor/YooAsset/YooAssetBuildHelper.meta
  22. 75 0
      Unity/Assets/Editor/YooAsset/YooAssetBuildHelper/BuildAB.cs
  23. 3 0
      Unity/Assets/Editor/YooAsset/YooAssetBuildHelper/BuildAB.cs.meta
  24. 24 0
      Unity/Assets/Editor/YooAsset/YooAssetBuildHelper/BuildSVC.cs
  25. 3 0
      Unity/Assets/Editor/YooAsset/YooAssetBuildHelper/BuildSVC.cs.meta
  26. 53 0
      Unity/Assets/Res/Shader/NewSurfaceShader.shader
  27. 10 0
      Unity/Assets/Res/Shader/NewSurfaceShader.shader.meta
  28. 58 0
      Unity/Assets/Res/Shader/NewUnlitShader.shader
  29. 10 0
      Unity/Assets/Res/Shader/NewUnlitShader.shader.meta
  30. 149 0
      Unity/Assets/Res/Shader/ProjectSShaderVariant.shadervariants
  31. 8 0
      Unity/Assets/Res/Shader/ProjectSShaderVariant.shadervariants.meta
  32. 332 0
      Unity/Assets/Res/Shader/ProjectSShaderVariant_Readme.json
  33. 7 0
      Unity/Assets/Res/Shader/ProjectSShaderVariant_Readme.json.meta
  34. 5 2
      Unity/Assets/Scripts/Loader/YooAssetMgr/YooAssetProxy.cs
  35. 15 0
      Unity/Assets/ShaderVariantCollectorSetting.asset
  36. 8 0
      Unity/Assets/ShaderVariantCollectorSetting.asset.meta

+ 2 - 2
.gitignore

@@ -13,7 +13,6 @@ Opt/
 
 */Temp/
 */TestResults/
-
 */.svn/
 .svn/
 bin/
@@ -79,4 +78,5 @@ Publish/
 StarEscortout/
 HybridCLRData/
 .vsconfig
-/Unity/Sandbox/CacheData.bytes
+/Unity/Sandbox
+/Unity/Bundles

+ 2 - 2
Unity/Assets/AssetBundleCollectorSetting.asset

@@ -73,12 +73,12 @@ MonoBehaviour:
     Collectors:
     - CollectPath: Assets/Res/FGUI
       CollectorType: 0
-      AddressRuleName: AddressByGroupAndFileName
+      AddressRuleName: AddressByCollectorAndFileName
       PackRuleName: PackDirectory
       FilterRuleName: CollectAll
       AssetTags: 
   - GroupName: Shader
-    GroupDesc: 
+    GroupDesc: "Shader\u6253\u5305"
     AssetTags: 
     ActiveRuleName: EnableGroup
     Collectors:

+ 8 - 0
Unity/Assets/Editor.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: fb3bb6a321c7e054e8bd90e0a007fb94
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 8 - 0
Unity/Assets/Editor/Helper.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 47d8599c1e489e14eaffbca1eaa91895
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 59 - 0
Unity/Assets/Editor/Helper/EditorResHelper.cs

@@ -0,0 +1,59 @@
+using System.Collections.Generic;
+using System.IO;
+
+namespace ET
+{
+    public class EditorResHelper
+    {
+        /// <summary>
+        /// 获取文件夹内所有的预制跟场景路径
+        /// </summary>
+        /// <param name="srcPath">源文件夹</param>
+        /// <param name="subDire">是否获取子文件夹</param>
+        /// <returns></returns>
+        public static List<string> GetPrefabsAndScenes(string srcPath)
+        {
+            List<string> paths = new List<string>();
+            FileHelper.GetAllFiles(paths, srcPath);
+            
+            List<string> files = new List<string>();
+            foreach (string str in paths)
+            {
+                if (str.EndsWith(".prefab") || str.EndsWith(".unity"))
+                {
+                    files.Add(str);
+                }
+            }
+            return files;
+        }
+        
+        /// <summary>
+        /// 获取文件夹内所有资源路径
+        /// </summary>
+        /// <param name="srcPath">源文件夹</param>
+        /// <param name="subDire">是否获取子文件夹</param>
+        /// <returns></returns>
+        public static List<string> GetAllResourcePath(string srcPath, bool subDire)
+        {
+            List<string> paths = new List<string>();
+            string[] files = Directory.GetFiles(srcPath);
+            foreach (string str in files)
+            {
+                if (str.EndsWith(".meta"))
+                {
+                    continue;
+                }
+                paths.Add(str);
+            }
+            if (subDire)
+            {
+                foreach (string subPath in Directory.GetDirectories(srcPath))
+                {
+                    List<string> subFiles = GetAllResourcePath(subPath, true);
+                    paths.AddRange(subFiles);
+                }
+            }
+            return paths;
+        }
+    }
+}

+ 3 - 0
Unity/Assets/Editor/Helper/EditorResHelper.cs.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 43d6132317ecb27499ed3fb707da46d1
+timeCreated: 1507865453

+ 129 - 0
Unity/Assets/Editor/Helper/ShellHelper.cs

@@ -0,0 +1,129 @@
+using System;
+using System.Diagnostics;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace ET
+{
+    public static class ShellHelper
+    {
+        private static string shellApp
+        {
+            get
+            {
+#if UNITY_EDITOR_WIN
+			    string app = "cmd.exe";
+#elif UNITY_EDITOR_OSX
+                string app = "bash";
+#endif
+                return app;
+            }
+        }
+
+        private static volatile bool isFinish;
+        
+        public static void Run(string cmd, string workDirectory, List<string> environmentVars = null)
+        {
+            Process p = null;
+            try
+            {
+                ProcessStartInfo start = new ProcessStartInfo(shellApp);
+
+#if UNITY_EDITOR_OSX
+                string splitChar = ":";
+                start.Arguments = "-c";
+#elif UNITY_EDITOR_WIN
+                string splitChar = ";";
+				start.Arguments = "/c";
+#endif
+
+                if (environmentVars != null)
+                {
+                    foreach (string var in environmentVars)
+                    {
+                        start.EnvironmentVariables["PATH"] += (splitChar + var);
+                    }
+                }
+
+                start.Arguments += (" \"" + cmd + "\"");
+                start.CreateNoWindow = true;
+                start.ErrorDialog = true;
+                start.UseShellExecute = false;
+                start.WorkingDirectory = workDirectory;
+
+                if (start.UseShellExecute)
+                {
+                    start.RedirectStandardOutput = false;
+                    start.RedirectStandardError = false;
+                    start.RedirectStandardInput = false;
+                }
+                else
+                {
+                    start.RedirectStandardOutput = true;
+                    start.RedirectStandardError = true;
+                    start.RedirectStandardInput = true;
+                    start.StandardOutputEncoding = System.Text.Encoding.UTF8;
+                    start.StandardErrorEncoding = System.Text.Encoding.UTF8;
+                }
+
+                
+
+                Barrier barrier = new Barrier(2);
+                
+                // 放到新线程启动进程,主线程循环读标准输出,直到进程结束
+                Task.Run(() =>
+                {
+                    p = Process.Start(start);
+                    barrier.RemoveParticipant();
+                    p.WaitForExit();
+                    isFinish = true;
+                });
+                
+                // 这里要等待进程启动才能往下走,否则p将为null
+                barrier.SignalAndWait();
+                do
+                {
+                    string line = p.StandardOutput.ReadLine();
+                    if (string.IsNullOrEmpty(line))
+                    {
+                        break;
+                    }
+
+                    line = line.Replace("\\", "/");
+
+                    UnityEngine.Debug.Log(line);
+                }
+                while (!isFinish);
+
+                bool hasError = false;
+                while (true)
+                {
+                    string error = p.StandardError.ReadLine();
+                    if (string.IsNullOrEmpty(error))
+                    {
+                        break;
+                    }
+
+                    hasError = true;
+                    UnityEngine.Debug.LogError(error);
+                }
+
+                
+                p.Close();
+                if (hasError)
+                {
+                    UnityEngine.Debug.LogError("has error!");
+                }
+            }
+            catch (Exception e)
+            {
+                UnityEngine.Debug.LogException(e);
+                if (p != null)
+                {
+                    p.Close();
+                }
+            }
+        }
+    }
+}

+ 11 - 0
Unity/Assets/Editor/Helper/ShellHelper.cs.meta

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

+ 8 - 0
Unity/Assets/Editor/YooAsset.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: bc1d7e6a7aeb2764a89abd79826bfe49
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 23 - 0
Unity/Assets/Editor/YooAsset/AssetBundleCollectorConfig.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root Version="1.0">
+  <Common AutoAddressable="True" AutoCollectShader="True" ShaderBundleName="myshaders" />
+  <Group GroupName="Code" GroupDesc="代码热更新dll" AssetTags="">
+    <Collector CollectPath="Assets/Res/Code" CollectType="MainAssetCollector" AddressRule="AddressByGroupAndFileName" PackRule="PackRawFile" FilterRule="CollectAll" AssetTags="" />
+  </Group>
+  <Group GroupName="Config" GroupDesc="配置表" AssetTags="">
+    <Collector CollectPath="Assets/Res/Config" CollectType="MainAssetCollector" AddressRule="AddressByGroupAndFileName" PackRule="PackDirectory" FilterRule="CollectAll" AssetTags="ConfigList" />
+  </Group>
+  <Group GroupName="UI" GroupDesc="UI相关" AssetTags="">
+    <Collector CollectPath="Assets/Res/UI" CollectType="MainAssetCollector" AddressRule="AddressByGroupAndFileName" PackRule="PackDirectory" FilterRule="CollectAll" AssetTags="" />
+  </Group>
+  <Group GroupName="Unit" GroupDesc="Unit" AssetTags="">
+    <Collector CollectPath="Assets/Res/Unit" CollectType="MainAssetCollector" AddressRule="AddressByGroupAndFileName" PackRule="PackDirectory" FilterRule="CollectAll" AssetTags="" />
+  </Group>
+  <Group GroupName="Scene" GroupDesc="场景" AssetTags="">
+    <Collector CollectPath="Assets/Res/Scene" CollectType="MainAssetCollector" AddressRule="AddressByGroupAndFileName" PackRule="PackDirectory" FilterRule="CollectScene" AssetTags="" />
+  </Group>
+  <Group GroupName="LightingMap" GroupDesc="光照数据" AssetTags="">
+    <Collector CollectPath="Assets/Res/Scene/Map1" CollectType="MainAssetCollector" AddressRule="AddressByCollectorAndFileName" PackRule="PackDirectory" FilterRule="CollectAll" AssetTags="" />
+    <Collector CollectPath="Assets/Res/Scene/Map2" CollectType="MainAssetCollector" AddressRule="AddressByCollectorAndFileName" PackRule="PackDirectory" FilterRule="CollectAll" AssetTags="" />
+  </Group>
+</root>

+ 7 - 0
Unity/Assets/Editor/YooAsset/AssetBundleCollectorConfig.xml.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 9ec50bf31d06109448da7642c7beba09
+TextScriptImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 8 - 0
Unity/Assets/Editor/YooAsset/Encryption.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: a8e453c4fd0ca744ab3e1adbe6064cbf
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 40 - 0
Unity/Assets/Editor/YooAsset/Encryption/ProjectSEncryption.cs

@@ -0,0 +1,40 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using YooAsset.Editor;
+
+public class EncryptionNone : IEncryptionServices
+{
+    bool IEncryptionServices.Check(string bundleName)
+    {
+        return false;
+    }
+    byte[] IEncryptionServices.Encrypt(byte[] fileData)
+    {
+        throw new System.NotImplementedException();
+    }
+}
+
+public class GameEncryption : IEncryptionServices
+{
+    /// <summary>
+    /// 检测资源包是否需要加密
+    /// </summary>
+    bool IEncryptionServices.Check(string bundleName)
+    {
+        // 对配置表进行加密
+        return bundleName.Contains("Config");
+    }
+
+    /// <summary>
+    /// 对数据进行加密,并返回加密后的数据
+    /// </summary>
+    byte[] IEncryptionServices.Encrypt(byte[] fileData)
+    {
+        int offset = 32;
+        var temper = new byte[fileData.Length + offset];
+        Buffer.BlockCopy(fileData, 0, temper, offset, fileData.Length);
+        return temper;
+    }
+}

+ 11 - 0
Unity/Assets/Editor/YooAsset/Encryption/ProjectSEncryption.cs.meta

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

+ 3 - 0
Unity/Assets/Editor/YooAsset/FilterRule.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: a1b68735de9248f9bbe0eb1d72b88cba
+timeCreated: 1658544869

+ 16 - 0
Unity/Assets/Editor/YooAsset/FilterRule/CollectShaderVariants.cs

@@ -0,0 +1,16 @@
+// Administrator20222310:562022
+
+using System.IO;
+using UnityEngine;
+using YooAsset.Editor;
+
+namespace ET
+{
+    public class CollectShaderVariants : IFilterRule
+    {
+        public bool IsCollectAsset(FilterRuleData data)
+        {
+            return Path.GetExtension(data.AssetPath) == ".shadervariants";		
+        }
+    }
+}

+ 3 - 0
Unity/Assets/Editor/YooAsset/FilterRule/CollectShaderVariants.cs.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: dca303992f7d4c14b8a8e52a25e790c2
+timeCreated: 1658545008

+ 3 - 0
Unity/Assets/Editor/YooAsset/PackRule.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 8d9dd6b6ad5b43e39f49a7e88ccce5be
+timeCreated: 1658544853

+ 18 - 0
Unity/Assets/Editor/YooAsset/PackRule/PackShaderVariants.cs

@@ -0,0 +1,18 @@
+// --------------------------
+// 作者:烟雨迷离半世殇
+// 邮箱:1778139321@qq.com
+// 日期:2022年7月23日, 星期六
+// --------------------------
+
+using YooAsset.Editor;
+
+namespace ET
+{
+    public class PackShaderVariants : IPackRule
+    {
+        public string GetBundleName(PackRuleData data)
+        {
+            return "projects_shaders";
+        }
+    }
+}

+ 3 - 0
Unity/Assets/Editor/YooAsset/PackRule/PackShaderVariants.cs.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 001340c726844aee83a09ac1b3619ebc
+timeCreated: 1658544962

+ 3 - 0
Unity/Assets/Editor/YooAsset/YooAssetBuildHelper.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 31acba44b4924e3884d5e28fbd2bd042
+timeCreated: 1658928861

+ 75 - 0
Unity/Assets/Editor/YooAsset/YooAssetBuildHelper/BuildAB.cs

@@ -0,0 +1,75 @@
+// --------------------------
+// 作者:烟雨迷离半世殇
+// 邮箱:1778139321@qq.com
+// 日期:2022年7月27日, 星期三
+// --------------------------
+
+using UnityEditor;
+using UnityEngine;
+using System.IO;
+using UnityEditor.SceneManagement;
+using YooAsset.Editor;
+
+namespace ET
+{
+    /// <summary>
+    /// 编辑器下一键Build AB
+    /// </summary>
+    /*public static class BuildABTool
+    {
+        [MonKey.Command("Build AB", "ProjectS编辑器下Build AB工具", Category = "Build")]
+        public static void BuildAB_Auto()
+        {
+            int cachedVersion = EditorPrefs.GetInt("YooAssetABVersion");
+            cachedVersion++;
+            EditorPrefs.SetInt("YooAssetABVersion", cachedVersion);
+            
+            BuildABWithVersion(cachedVersion);
+        }
+
+        public static void BuildABWithVersion(int buildVersion = 0)
+        {
+            Debug.Log($"开始构建AB,平台为:{EditorUserBuildSettings.activeBuildTarget} Version为 {buildVersion}");
+
+            EditorSceneManager.OpenScene(GlobalDefine.InitScenePath);
+
+            // 构建参数
+            string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultOutputRoot();
+            BuildParameters buildParameters = new BuildParameters();
+            buildParameters.OutputRoot = defaultOutputRoot;
+            buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
+            buildParameters.BuildPipeline = EBuildPipeline.BuiltinBuildPipeline;
+            buildParameters.BuildMode = EBuildMode.IncrementalBuild;
+            buildParameters.BuildVersion = buildVersion;
+            buildParameters.BuildinTags = "buildin";
+            buildParameters.VerifyBuildingResult = true;
+            buildParameters.EnableAddressable = true;
+            buildParameters.CopyBuildinTagFiles = true;
+            buildParameters.EncryptionServices = new GameEncryption();
+            buildParameters.CompressOption = ECompressOption.LZ4;
+
+            // 执行构建
+            AssetBundleBuilder builder = new AssetBundleBuilder();
+            bool succeed = builder.Run(buildParameters);
+
+            // 需要对构建出的AB包进行后处理
+            // 1. 更改文件夹名为App version名
+            // 2. 将文件夹移动到同父级目录的CDN文件夹下
+            string oriABPath =
+                $"{buildParameters.OutputRoot}/{EditorUserBuildSettings.activeBuildTarget}/{buildVersion}";
+            string finalABDir =
+                $"{buildParameters.OutputRoot}/CDN/{EditorUserBuildSettings.activeBuildTarget}";
+            string finalABPath =
+                $"{buildParameters.OutputRoot}/CDN/{EditorUserBuildSettings.activeBuildTarget}/{Init.Instance.Version}";
+            if (Directory.Exists(finalABDir))
+            {
+                Directory.Delete(finalABDir, true);
+            }
+
+            Directory.CreateDirectory(finalABDir);
+            Directory.Move(oriABPath, finalABPath);
+
+            Debug.Log($"构建AB结果:{succeed},将{oriABPath}移动到{finalABPath}");
+        }
+    }*/
+}

+ 3 - 0
Unity/Assets/Editor/YooAsset/YooAssetBuildHelper/BuildAB.cs.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: f3ceb84cb6774d328472bb594416b502
+timeCreated: 1658928870

+ 24 - 0
Unity/Assets/Editor/YooAsset/YooAssetBuildHelper/BuildSVC.cs

@@ -0,0 +1,24 @@
+// --------------------------
+// 作者:烟雨迷离半世殇
+// 邮箱:1778139321@qq.com
+// 日期:2022年7月27日, 星期三
+// --------------------------
+
+using UnityEditor.SceneManagement;
+using UnityEngine;
+using YooAsset.Editor;
+
+namespace ET
+{
+    public class BuildSVC
+    {
+        /*[MonKey.Command("Build SVC", "ProjectS编辑器下Build SVC工具", Category = "Build")]
+        public static void BuildSVC_Auto()
+        {
+            ShaderVariantCollector.Run(ShaderVariantCollectorSettingData.Setting.SavePath, () =>
+            {
+                EditorSceneManager.OpenScene(GlobalDefine.InitScenePath);
+            });
+        }*/
+    }
+}

+ 3 - 0
Unity/Assets/Editor/YooAsset/YooAssetBuildHelper/BuildSVC.cs.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 43a9cfaa04e1430eb54e3a99088686a8
+timeCreated: 1658929470

+ 53 - 0
Unity/Assets/Res/Shader/NewSurfaceShader.shader

@@ -0,0 +1,53 @@
+Shader "Custom/NewSurfaceShader"
+{
+    Properties
+    {
+        _Color ("Color", Color) = (1,1,1,1)
+        _MainTex ("Albedo (RGB)", 2D) = "white" {}
+        _Glossiness ("Smoothness", Range(0,1)) = 0.5
+        _Metallic ("Metallic", Range(0,1)) = 0.0
+    }
+    SubShader
+    {
+        Tags { "RenderType"="Opaque" }
+        LOD 200
+
+        CGPROGRAM
+        // Physically based Standard lighting model, and enable shadows on all light types
+        #pragma surface surf Standard fullforwardshadows
+
+        // Use shader model 3.0 target, to get nicer looking lighting
+        #pragma target 3.0
+
+        sampler2D _MainTex;
+
+        struct Input
+        {
+            float2 uv_MainTex;
+        };
+
+        half _Glossiness;
+        half _Metallic;
+        fixed4 _Color;
+
+        // Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
+        // See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
+        // #pragma instancing_options assumeuniformscaling
+        UNITY_INSTANCING_BUFFER_START(Props)
+            // put more per-instance properties here
+        UNITY_INSTANCING_BUFFER_END(Props)
+
+        void surf (Input IN, inout SurfaceOutputStandard o)
+        {
+            // Albedo comes from a texture tinted by color
+            fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
+            o.Albedo = c.rgb;
+            // Metallic and smoothness come from slider variables
+            o.Metallic = _Metallic;
+            o.Smoothness = _Glossiness;
+            o.Alpha = c.a;
+        }
+        ENDCG
+    }
+    FallBack "Diffuse"
+}

+ 10 - 0
Unity/Assets/Res/Shader/NewSurfaceShader.shader.meta

@@ -0,0 +1,10 @@
+fileFormatVersion: 2
+guid: a098bd7d5939c054982999a9523191df
+ShaderImporter:
+  externalObjects: {}
+  defaultTextures: []
+  nonModifiableTextures: []
+  preprocessorOverride: 0
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 58 - 0
Unity/Assets/Res/Shader/NewUnlitShader.shader

@@ -0,0 +1,58 @@
+Shader "Unlit/NewUnlitShader"
+{
+    Properties
+    {
+        _MainTex ("Texture", 2D) = "white" {}
+    }
+    SubShader
+    {
+        Tags { "RenderType"="Opaque" }
+        LOD 100
+
+        Pass
+        {
+            CGPROGRAM
+            #pragma vertex vert
+            #pragma fragment frag
+            // make fog work
+            #pragma multi_compile_fog
+
+            #include "UnityCG.cginc"
+
+            struct appdata
+            {
+                float4 vertex : POSITION;
+                float2 uv : TEXCOORD0;
+            };
+
+            struct v2f
+            {
+                float2 uv : TEXCOORD0;
+                UNITY_FOG_COORDS(1)
+                float4 vertex : SV_POSITION;
+            };
+
+            sampler2D _MainTex;
+            float4 _MainTex_ST;
+
+            v2f vert (appdata v)
+            {
+                v2f o;
+                o.vertex = UnityObjectToClipPos(v.vertex);
+                o.uv = TRANSFORM_TEX(v.uv, _MainTex);
+                UNITY_TRANSFER_FOG(o,o.vertex);
+                return o;
+            }
+
+            fixed4 frag (v2f i) : SV_Target
+            {
+                // sample the texture
+                fixed4 col = tex2D(_MainTex, i.uv);
+                // apply fog
+                UNITY_APPLY_FOG(i.fogCoord, col);
+                return col;
+            }
+            ENDCG
+        }
+    }
+}

+ 10 - 0
Unity/Assets/Res/Shader/NewUnlitShader.shader.meta

@@ -0,0 +1,10 @@
+fileFormatVersion: 2
+guid: 718489c739fa0924eb3bc03cac3bb7a8
+ShaderImporter:
+  externalObjects: {}
+  defaultTextures: []
+  nonModifiableTextures: []
+  preprocessorOverride: 0
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 149 - 0
Unity/Assets/Res/Shader/ProjectSShaderVariant.shadervariants

@@ -0,0 +1,149 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!200 &20000000
+ShaderVariantCollection:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_Name: ProjectSShaderVariant
+  m_Shaders:
+  - first: {fileID: 66, guid: 0000000000000000f000000000000000, type: 0}
+    second:
+      variants:
+      - keywords: 
+        passType: 0
+  - first: {fileID: 106, guid: 0000000000000000f000000000000000, type: 0}
+    second:
+      variants:
+      - keywords: _SUNDISK_SIMPLE
+        passType: 0
+      - keywords: BILLBOARD_FACE_CAMERA_POS _DEPTH_NO_MSAA _SUNDISK_SIMPLE
+        passType: 0
+      - keywords: BILLBOARD_FACE_CAMERA_POS UNITY_HDR_ON _DEPTH_NO_MSAA _SUNDISK_SIMPLE
+        passType: 0
+  - first: {fileID: 9000, guid: 0000000000000000f000000000000000, type: 0}
+    second:
+      variants:
+      - keywords: 
+        passType: 0
+  - first: {fileID: 9001, guid: 0000000000000000f000000000000000, type: 0}
+    second:
+      variants:
+      - keywords: 
+        passType: 0
+  - first: {fileID: 9002, guid: 0000000000000000f000000000000000, type: 0}
+    second:
+      variants:
+      - keywords: 
+        passType: 0
+  - first: {fileID: 9003, guid: 0000000000000000f000000000000000, type: 0}
+    second:
+      variants:
+      - keywords: 
+        passType: 0
+  - first: {fileID: 9004, guid: 0000000000000000f000000000000000, type: 0}
+    second:
+      variants:
+      - keywords: 
+        passType: 0
+  - first: {fileID: 9007, guid: 0000000000000000f000000000000000, type: 0}
+    second:
+      variants:
+      - keywords: 
+        passType: 0
+  - first: {fileID: 9101, guid: 0000000000000000f000000000000000, type: 0}
+    second:
+      variants:
+      - keywords: 
+        passType: 0
+  - first: {fileID: 9103, guid: 0000000000000000f000000000000000, type: 0}
+    second:
+      variants:
+      - keywords: 
+        passType: 0
+      - keywords: BILLBOARD_FACE_CAMERA_POS _DEPTH_NO_MSAA
+        passType: 0
+      - keywords: BILLBOARD_FACE_CAMERA_POS UNITY_HDR_ON _DEPTH_NO_MSAA
+        passType: 0
+  - first: {fileID: 10750, guid: 0000000000000000f000000000000000, type: 0}
+    second:
+      variants:
+      - keywords: 
+        passType: 0
+  - first: {fileID: 4800000, guid: c17132b1f77d20942aa75f8429c0f8bc, type: 3}
+    second:
+      variants:
+      - keywords: 
+        passType: 0
+      - keywords: BILLBOARD_FACE_CAMERA_POS _DEPTH_NO_MSAA
+        passType: 0
+  - first: {fileID: 4800000, guid: d6dae50ee9e1bfa4db75f19f99355220, type: 3}
+    second:
+      variants:
+      - keywords: 
+        passType: 0
+      - keywords: BILLBOARD_FACE_CAMERA_POS UNITY_HDR_ON _DEPTH_NO_MSAA
+        passType: 0
+  - first: {fileID: 4800000, guid: 65df88701913c224d95fc554db28381a, type: 3}
+    second:
+      variants:
+      - keywords: 
+        passType: 0
+      - keywords: BILLBOARD_FACE_CAMERA_POS UNITY_HDR_ON _DEPTH_NO_MSAA
+        passType: 0
+  - first: {fileID: 4800000, guid: e7857e9d0c934dc4f83f270f8447b006, type: 3}
+    second:
+      variants:
+      - keywords: 
+        passType: 0
+      - keywords: BILLBOARD_FACE_CAMERA_POS UNITY_HDR_ON _DEPTH_NO_MSAA
+        passType: 0
+  - first: {fileID: 4800000, guid: 718489c739fa0924eb3bc03cac3bb7a8, type: 3}
+    second:
+      variants:
+      - keywords: 
+        passType: 0
+  - first: {fileID: 4800000, guid: e260cfa7296ee7642b167f1eb5be5023, type: 3}
+    second:
+      variants:
+      - keywords: 
+        passType: 13
+  - first: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
+    second:
+      variants:
+      - keywords: 
+        passType: 8
+      - keywords: _ALPHATEST_ON
+        passType: 8
+      - keywords: _ALPHATEST_ON _RECEIVE_SHADOWS_OFF
+        passType: 8
+      - keywords: 
+        passType: 13
+      - keywords: _MAIN_LIGHT_SHADOWS
+        passType: 13
+      - keywords: _MAIN_LIGHT_SHADOWS _RECEIVE_SHADOWS_OFF
+        passType: 13
+      - keywords: _ALPHATEST_ON
+        passType: 13
+      - keywords: _ALPHATEST_ON _MAIN_LIGHT_SHADOWS _SHADOWS_SOFT
+        passType: 13
+      - keywords: _ALPHATEST_ON _MAIN_LIGHT_SHADOWS _RECEIVE_SHADOWS_OFF _SHADOWS_SOFT
+        passType: 13
+  - first: {fileID: 4800000, guid: 650dd9526735d5b46b79224bc6e94025, type: 3}
+    second:
+      variants:
+      - keywords: 
+        passType: 0
+      - keywords: 
+        passType: 13
+  - first: {fileID: 4800000, guid: 6c78a6dd468954643a87ebf0014bc305, type: 3}
+    second:
+      variants:
+      - keywords: 
+        passType: 0
+  - first: {fileID: 4800000, guid: 6dad35c0b62e44c26ab244ad80deee1a, type: 3}
+    second:
+      variants:
+      - keywords: 
+        passType: 0

+ 8 - 0
Unity/Assets/Res/Shader/ProjectSShaderVariant.shadervariants.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 54abdc6482fd89b4a95f4ec2edf62e05
+NativeFormatImporter:
+  externalObjects: {}
+  mainObjectFileID: 20000000
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 332 - 0
Unity/Assets/Res/Shader/ProjectSShaderVariant_Readme.json

@@ -0,0 +1,332 @@
+{
+    "ShaderCount": 0,
+    "VariantCount": 0,
+    "ShaderVariants": [
+        {
+            "AssetPath": "Resources/unity_builtin_extra",
+            "ShaderName": "Hidden/BlitCopy",
+            "PassType": 0,
+            "Keywords": [
+                ""
+            ]
+        },
+        {
+            "AssetPath": "Resources/unity_builtin_extra",
+            "ShaderName": "Skybox/Procedural",
+            "PassType": 0,
+            "Keywords": [
+                "_SUNDISK_SIMPLE"
+            ]
+        },
+        {
+            "AssetPath": "Resources/unity_builtin_extra",
+            "ShaderName": "Skybox/Procedural",
+            "PassType": 0,
+            "Keywords": [
+                "BILLBOARD_FACE_CAMERA_POS",
+                "_DEPTH_NO_MSAA",
+                "_SUNDISK_SIMPLE"
+            ]
+        },
+        {
+            "AssetPath": "Resources/unity_builtin_extra",
+            "ShaderName": "Skybox/Procedural",
+            "PassType": 0,
+            "Keywords": [
+                "BILLBOARD_FACE_CAMERA_POS",
+                "UNITY_HDR_ON",
+                "_DEPTH_NO_MSAA",
+                "_SUNDISK_SIMPLE"
+            ]
+        },
+        {
+            "AssetPath": "Resources/unity_builtin_extra",
+            "ShaderName": "Hidden/Internal-GUITextureClip",
+            "PassType": 0,
+            "Keywords": [
+                ""
+            ]
+        },
+        {
+            "AssetPath": "Resources/unity_builtin_extra",
+            "ShaderName": "Hidden/Internal-GUITextureClipText",
+            "PassType": 0,
+            "Keywords": [
+                ""
+            ]
+        },
+        {
+            "AssetPath": "Resources/unity_builtin_extra",
+            "ShaderName": "Hidden/Internal-GUITexture",
+            "PassType": 0,
+            "Keywords": [
+                ""
+            ]
+        },
+        {
+            "AssetPath": "Resources/unity_builtin_extra",
+            "ShaderName": "Hidden/Internal-GUITextureBlit",
+            "PassType": 0,
+            "Keywords": [
+                ""
+            ]
+        },
+        {
+            "AssetPath": "Resources/unity_builtin_extra",
+            "ShaderName": "Hidden/Internal-GUIRoundedRect",
+            "PassType": 0,
+            "Keywords": [
+                ""
+            ]
+        },
+        {
+            "AssetPath": "Resources/unity_builtin_extra",
+            "ShaderName": "Hidden/Internal-GUIRoundedRectWithColorPerBorder",
+            "PassType": 0,
+            "Keywords": [
+                ""
+            ]
+        },
+        {
+            "AssetPath": "Resources/unity_builtin_extra",
+            "ShaderName": "Hidden/Internal-UIRAtlasBlitCopy",
+            "PassType": 0,
+            "Keywords": [
+                ""
+            ]
+        },
+        {
+            "AssetPath": "Resources/unity_builtin_extra",
+            "ShaderName": "Hidden/UIElements/EditorUIE",
+            "PassType": 0,
+            "Keywords": [
+                ""
+            ]
+        },
+        {
+            "AssetPath": "Resources/unity_builtin_extra",
+            "ShaderName": "Hidden/UIElements/EditorUIE",
+            "PassType": 0,
+            "Keywords": [
+                "BILLBOARD_FACE_CAMERA_POS",
+                "_DEPTH_NO_MSAA"
+            ]
+        },
+        {
+            "AssetPath": "Resources/unity_builtin_extra",
+            "ShaderName": "Hidden/UIElements/EditorUIE",
+            "PassType": 0,
+            "Keywords": [
+                "BILLBOARD_FACE_CAMERA_POS",
+                "UNITY_HDR_ON",
+                "_DEPTH_NO_MSAA"
+            ]
+        },
+        {
+            "AssetPath": "Resources/unity_builtin_extra",
+            "ShaderName": "Unlit/Transparent",
+            "PassType": 0,
+            "Keywords": [
+                ""
+            ]
+        },
+        {
+            "AssetPath": "Packages/com.unity.render-pipelines.universal/Shaders/Utils/Blit.shader",
+            "ShaderName": "Hidden/Universal Render Pipeline/Blit",
+            "PassType": 0,
+            "Keywords": [
+                ""
+            ]
+        },
+        {
+            "AssetPath": "Packages/com.unity.render-pipelines.universal/Shaders/Utils/Blit.shader",
+            "ShaderName": "Hidden/Universal Render Pipeline/Blit",
+            "PassType": 0,
+            "Keywords": [
+                "BILLBOARD_FACE_CAMERA_POS",
+                "_DEPTH_NO_MSAA"
+            ]
+        },
+        {
+            "AssetPath": "Packages/com.unity.render-pipelines.universal/Shaders/Utils/CopyDepth.shader",
+            "ShaderName": "Hidden/Universal Render Pipeline/CopyDepth",
+            "PassType": 0,
+            "Keywords": [
+                ""
+            ]
+        },
+        {
+            "AssetPath": "Packages/com.unity.render-pipelines.universal/Shaders/Utils/CopyDepth.shader",
+            "ShaderName": "Hidden/Universal Render Pipeline/CopyDepth",
+            "PassType": 0,
+            "Keywords": [
+                "BILLBOARD_FACE_CAMERA_POS",
+                "UNITY_HDR_ON",
+                "_DEPTH_NO_MSAA"
+            ]
+        },
+        {
+            "AssetPath": "Packages/com.unity.render-pipelines.universal/Shaders/PostProcessing/LutBuilderLdr.shader",
+            "ShaderName": "Hidden/Universal Render Pipeline/LutBuilderLdr",
+            "PassType": 0,
+            "Keywords": [
+                ""
+            ]
+        },
+        {
+            "AssetPath": "Packages/com.unity.render-pipelines.universal/Shaders/PostProcessing/LutBuilderLdr.shader",
+            "ShaderName": "Hidden/Universal Render Pipeline/LutBuilderLdr",
+            "PassType": 0,
+            "Keywords": [
+                "BILLBOARD_FACE_CAMERA_POS",
+                "UNITY_HDR_ON",
+                "_DEPTH_NO_MSAA"
+            ]
+        },
+        {
+            "AssetPath": "Packages/com.unity.render-pipelines.universal/Shaders/PostProcessing/UberPost.shader",
+            "ShaderName": "Hidden/Universal Render Pipeline/UberPost",
+            "PassType": 0,
+            "Keywords": [
+                ""
+            ]
+        },
+        {
+            "AssetPath": "Packages/com.unity.render-pipelines.universal/Shaders/PostProcessing/UberPost.shader",
+            "ShaderName": "Hidden/Universal Render Pipeline/UberPost",
+            "PassType": 0,
+            "Keywords": [
+                "BILLBOARD_FACE_CAMERA_POS",
+                "UNITY_HDR_ON",
+                "_DEPTH_NO_MSAA"
+            ]
+        },
+        {
+            "AssetPath": "Assets/Res/Shader/NewUnlitShader.shader",
+            "ShaderName": "Unlit/NewUnlitShader",
+            "PassType": 0,
+            "Keywords": [
+                ""
+            ]
+        },
+        {
+            "AssetPath": "Packages/com.unity.render-pipelines.universal/Shaders/2D/Sprite-Lit-Default.shader",
+            "ShaderName": "Universal Render Pipeline/2D/Sprite-Lit-Default",
+            "PassType": 13,
+            "Keywords": [
+                ""
+            ]
+        },
+        {
+            "AssetPath": "Packages/com.unity.render-pipelines.universal/Shaders/Lit.shader",
+            "ShaderName": "Universal Render Pipeline/Lit",
+            "PassType": 8,
+            "Keywords": [
+                ""
+            ]
+        },
+        {
+            "AssetPath": "Packages/com.unity.render-pipelines.universal/Shaders/Lit.shader",
+            "ShaderName": "Universal Render Pipeline/Lit",
+            "PassType": 8,
+            "Keywords": [
+                "_ALPHATEST_ON"
+            ]
+        },
+        {
+            "AssetPath": "Packages/com.unity.render-pipelines.universal/Shaders/Lit.shader",
+            "ShaderName": "Universal Render Pipeline/Lit",
+            "PassType": 8,
+            "Keywords": [
+                "_ALPHATEST_ON",
+                "_RECEIVE_SHADOWS_OFF"
+            ]
+        },
+        {
+            "AssetPath": "Packages/com.unity.render-pipelines.universal/Shaders/Lit.shader",
+            "ShaderName": "Universal Render Pipeline/Lit",
+            "PassType": 13,
+            "Keywords": [
+                ""
+            ]
+        },
+        {
+            "AssetPath": "Packages/com.unity.render-pipelines.universal/Shaders/Lit.shader",
+            "ShaderName": "Universal Render Pipeline/Lit",
+            "PassType": 13,
+            "Keywords": [
+                "_MAIN_LIGHT_SHADOWS"
+            ]
+        },
+        {
+            "AssetPath": "Packages/com.unity.render-pipelines.universal/Shaders/Lit.shader",
+            "ShaderName": "Universal Render Pipeline/Lit",
+            "PassType": 13,
+            "Keywords": [
+                "_MAIN_LIGHT_SHADOWS",
+                "_RECEIVE_SHADOWS_OFF"
+            ]
+        },
+        {
+            "AssetPath": "Packages/com.unity.render-pipelines.universal/Shaders/Lit.shader",
+            "ShaderName": "Universal Render Pipeline/Lit",
+            "PassType": 13,
+            "Keywords": [
+                "_ALPHATEST_ON"
+            ]
+        },
+        {
+            "AssetPath": "Packages/com.unity.render-pipelines.universal/Shaders/Lit.shader",
+            "ShaderName": "Universal Render Pipeline/Lit",
+            "PassType": 13,
+            "Keywords": [
+                "_ALPHATEST_ON",
+                "_MAIN_LIGHT_SHADOWS",
+                "_SHADOWS_SOFT"
+            ]
+        },
+        {
+            "AssetPath": "Packages/com.unity.render-pipelines.universal/Shaders/Lit.shader",
+            "ShaderName": "Universal Render Pipeline/Lit",
+            "PassType": 13,
+            "Keywords": [
+                "_ALPHATEST_ON",
+                "_MAIN_LIGHT_SHADOWS",
+                "_RECEIVE_SHADOWS_OFF",
+                "_SHADOWS_SOFT"
+            ]
+        },
+        {
+            "AssetPath": "Packages/com.unity.render-pipelines.universal/Shaders/Unlit.shader",
+            "ShaderName": "Universal Render Pipeline/Unlit",
+            "PassType": 0,
+            "Keywords": [
+                ""
+            ]
+        },
+        {
+            "AssetPath": "Packages/com.unity.render-pipelines.universal/Shaders/Unlit.shader",
+            "ShaderName": "Universal Render Pipeline/Unlit",
+            "PassType": 13,
+            "Keywords": [
+                ""
+            ]
+        },
+        {
+            "AssetPath": "Assets/Plugins/AstarPathfindingProject/Editor/EditorAssets/Materials/NavmeshOutline.shader",
+            "ShaderName": "Hidden/AstarPathfindingProject/Navmesh Outline",
+            "PassType": 0,
+            "Keywords": [
+                ""
+            ]
+        },
+        {
+            "AssetPath": "Assets/Plugins/AstarPathfindingProject/Editor/EditorAssets/Materials/Navmesh.shader",
+            "ShaderName": "Hidden/AstarPathfindingProject/Navmesh",
+            "PassType": 0,
+            "Keywords": [
+                ""
+            ]
+        }
+    ]
+}

+ 7 - 0
Unity/Assets/Res/Shader/ProjectSShaderVariant_Readme.json.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 38836c7248abcf44492ac6d18222bfc7
+TextScriptImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 5 - 2
Unity/Assets/Scripts/Loader/YooAssetMgr/YooAssetProxy.cs

@@ -147,8 +147,11 @@ namespace ET
                 createParameters.LocationServices = new AddressLocationServices();
                 createParameters.DecryptionServices = null;
                 createParameters.ClearCacheWhenDirty = false;
-                createParameters.DefaultHostServer = GetHostServerURL();
-                createParameters.FallbackHostServer = GetHostServerURL();
+
+                var hostServer = GetHostServerURL();
+                createParameters.DefaultHostServer = hostServer;
+                //作为DefaultHostServer的备份
+                createParameters.FallbackHostServer = hostServer;
 				//设置大于1Mb的资源支持断点续传
                 createParameters.BreakpointResumeFileSize = 1 * 1014 * 1024;
                 string GetHostServerURL()

+ 15 - 0
Unity/Assets/ShaderVariantCollectorSetting.asset

@@ -0,0 +1,15 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!114 &11400000
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 0}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 44454e58a49818040a1aef5799e71b30, type: 3}
+  m_Name: ShaderVariantCollectorSetting
+  m_EditorClassIdentifier: 
+  SavePath: iantss/Res/Shader/ProjectSShaderVariant.shadervariants

+ 8 - 0
Unity/Assets/ShaderVariantCollectorSetting.asset.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 0e3532c46e605ca429dbe04f66d8d094
+NativeFormatImporter:
+  externalObjects: {}
+  mainObjectFileID: 11400000
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: