Commit 8d2444857d3c9daa06e735d460fee33b2d44a44a
0 parents
first commit
Showing
15 changed files
with
697 additions
and
0 deletions
Show diff stats
No preview for this file type
| 1 | +++ a/Editor/BuildEditor/BuildAssemblieEditor.cs | ||
| @@ -0,0 +1,154 @@ | @@ -0,0 +1,154 @@ | ||
| 1 | +// using System; | ||
| 2 | +// using System.Collections.Generic; | ||
| 3 | +// using System.IO; | ||
| 4 | +// using System.Linq; | ||
| 5 | +// using System.Threading; | ||
| 6 | +// using UnityEngine; | ||
| 7 | +// using UnityEditor; | ||
| 8 | +// using UnityEditor.Compilation; | ||
| 9 | +// using Random = UnityEngine.Random; | ||
| 10 | +// | ||
| 11 | +// namespace ZhaoluGame | ||
| 12 | +// { | ||
| 13 | +// public static class BuildAssemblieEditor | ||
| 14 | +// { | ||
| 15 | +// [MenuItem("Tools/Build/EnableAutoBuildCodeDebug _F1")] | ||
| 16 | +// public static void SetAutoBuildCode() | ||
| 17 | +// { | ||
| 18 | +// PlayerPrefs.SetInt("AutoBuild", 1); | ||
| 19 | +// EditorNotificationHelper.ShowNotification("AutoBuildCode Enabled"); | ||
| 20 | +// } | ||
| 21 | +// | ||
| 22 | +// [MenuItem("Tools/Build/DisableAutoBuildCodeDebug _F2")] | ||
| 23 | +// public static void CancelAutoBuildCode() | ||
| 24 | +// { | ||
| 25 | +// PlayerPrefs.DeleteKey("AutoBuild"); | ||
| 26 | +// EditorNotificationHelper.ShowNotification("AutoBuildCode Disabled"); | ||
| 27 | +// } | ||
| 28 | +// | ||
| 29 | +// [MenuItem("Tools/Build/BuildCodeRelease _F6")] | ||
| 30 | +// public static void BuildCodeRelease() | ||
| 31 | +// { | ||
| 32 | +// BuildAssemblieEditor.BuildMuteAssembly("HotfixCode", new[] | ||
| 33 | +// { | ||
| 34 | +// "HotfixCode/", | ||
| 35 | +// }, Array.Empty<string>(), CodeOptimization.Release); | ||
| 36 | +// | ||
| 37 | +// AfterCompiling(); | ||
| 38 | +// | ||
| 39 | +// AssetDatabase.Refresh(); | ||
| 40 | +// } | ||
| 41 | +// | ||
| 42 | +// private static void BuildMuteAssembly(string assemblyName, string[] CodeDirectorys, | ||
| 43 | +// string[] additionalReferences, CodeOptimization codeOptimization) | ||
| 44 | +// { | ||
| 45 | +// List<string> scripts = new List<string>(); | ||
| 46 | +// for (int i = 0; i < CodeDirectorys.Length; i++) | ||
| 47 | +// { | ||
| 48 | +// DirectoryInfo dti = new DirectoryInfo(CodeDirectorys[i]); | ||
| 49 | +// FileInfo[] fileInfos = dti.GetFiles("*.cs", System.IO.SearchOption.AllDirectories); | ||
| 50 | +// for (int j = 0; j < fileInfos.Length; j++) | ||
| 51 | +// { | ||
| 52 | +// scripts.Add(fileInfos[j].FullName); | ||
| 53 | +// } | ||
| 54 | +// } | ||
| 55 | +// | ||
| 56 | +// string dllPath = Path.Combine(Define.BuildOutputDir, $"{assemblyName}.dll"); | ||
| 57 | +// string pdbPath = Path.Combine(Define.BuildOutputDir, $"{assemblyName}.pdb"); | ||
| 58 | +// File.Delete(dllPath); | ||
| 59 | +// File.Delete(pdbPath); | ||
| 60 | +// | ||
| 61 | +// Directory.CreateDirectory(Define.BuildOutputDir); | ||
| 62 | +// | ||
| 63 | +// AssemblyBuilder assemblyBuilder = new AssemblyBuilder(dllPath, scripts.ToArray()); | ||
| 64 | +// | ||
| 65 | +// //启用UnSafe | ||
| 66 | +// //assemblyBuilder.compilerOptions.AllowUnsafeCode = true; | ||
| 67 | +// | ||
| 68 | +// BuildTargetGroup buildTargetGroup = | ||
| 69 | +// BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget); | ||
| 70 | +// | ||
| 71 | +// assemblyBuilder.compilerOptions.CodeOptimization = codeOptimization; | ||
| 72 | +// assemblyBuilder.compilerOptions.ApiCompatibilityLevel = | ||
| 73 | +// PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup); | ||
| 74 | +// // assemblyBuilder.compilerOptions.ApiCompatibilityLevel = ApiCompatibilityLevel.NET_4_6; | ||
| 75 | +// | ||
| 76 | +// assemblyBuilder.additionalReferences = additionalReferences; | ||
| 77 | +// | ||
| 78 | +// assemblyBuilder.flags = AssemblyBuilderFlags.None; | ||
| 79 | +// //AssemblyBuilderFlags.None 正常发布 | ||
| 80 | +// //AssemblyBuilderFlags.DevelopmentBuild 开发模式打包 | ||
| 81 | +// //AssemblyBuilderFlags.EditorAssembly 编辑器状态 | ||
| 82 | +// assemblyBuilder.referencesOptions = ReferencesOptions.UseEngineModules; | ||
| 83 | +// | ||
| 84 | +// assemblyBuilder.buildTarget = EditorUserBuildSettings.activeBuildTarget; | ||
| 85 | +// | ||
| 86 | +// assemblyBuilder.buildTargetGroup = buildTargetGroup; | ||
| 87 | +// | ||
| 88 | +// assemblyBuilder.buildStarted += delegate(string assemblyPath) | ||
| 89 | +// { | ||
| 90 | +// Debug.LogFormat("build start:" + assemblyPath); | ||
| 91 | +// }; | ||
| 92 | +// | ||
| 93 | +// assemblyBuilder.buildFinished += delegate(string assemblyPath, CompilerMessage[] compilerMessages) | ||
| 94 | +// { | ||
| 95 | +// int errorCount = compilerMessages.Count(m => m.type == CompilerMessageType.Error); | ||
| 96 | +// int warningCount = compilerMessages.Count(m => m.type == CompilerMessageType.Warning); | ||
| 97 | +// | ||
| 98 | +// Debug.LogFormat("Warnings: {0} - Errors: {1}", warningCount, errorCount); | ||
| 99 | +// | ||
| 100 | +// if (warningCount > 0) | ||
| 101 | +// { | ||
| 102 | +// Debug.LogFormat("有{0}个Warning!!!", warningCount); | ||
| 103 | +// } | ||
| 104 | +// | ||
| 105 | +// if (errorCount > 0) | ||
| 106 | +// { | ||
| 107 | +// for (int i = 0; i < compilerMessages.Length; i++) | ||
| 108 | +// { | ||
| 109 | +// if (compilerMessages[i].type == CompilerMessageType.Error) | ||
| 110 | +// { | ||
| 111 | +// Debug.LogError(compilerMessages[i].message); | ||
| 112 | +// } | ||
| 113 | +// } | ||
| 114 | +// } | ||
| 115 | +// }; | ||
| 116 | +// | ||
| 117 | +// //开始构建 | ||
| 118 | +// if (!assemblyBuilder.Build()) | ||
| 119 | +// { | ||
| 120 | +// Debug.LogErrorFormat("build fail:" + assemblyBuilder.assemblyPath); | ||
| 121 | +// return; | ||
| 122 | +// } | ||
| 123 | +// } | ||
| 124 | +// | ||
| 125 | +// private static void AfterCompiling() | ||
| 126 | +// { | ||
| 127 | +// while (EditorApplication.isCompiling) | ||
| 128 | +// { | ||
| 129 | +// Debug.Log("Compiling wait1"); | ||
| 130 | +// // 主线程sleep并不影响编译线程 | ||
| 131 | +// Thread.Sleep(1000); | ||
| 132 | +// Debug.Log("Compiling wait2"); | ||
| 133 | +// } | ||
| 134 | +// | ||
| 135 | +// Debug.Log("Compiling finish"); | ||
| 136 | +// | ||
| 137 | +// Directory.CreateDirectory(Define.HotfixCodeDir); | ||
| 138 | +// File.Copy(Path.Combine(Define.BuildOutputDir, "HotfixCode.dll"), | ||
| 139 | +// Path.Combine(Define.HotfixCodeDir, "HotfixCode.dll.bytes"), true); | ||
| 140 | +// File.Copy(Path.Combine(Define.BuildOutputDir, "HotfixCode.pdb"), | ||
| 141 | +// Path.Combine(Define.HotfixCodeDir, "HotfixCode.pdb.bytes"), true); | ||
| 142 | +// | ||
| 143 | +// // File.Copy(Path.Combine(Define.BuildOutputDir, "HotfixCode.dll"), Path.Combine(Define.HotfixCodeEditorDir, "HotfixCode.dll"), true); | ||
| 144 | +// // File.Copy(Path.Combine(Define.BuildOutputDir, "HotfixCode.pdb"), Path.Combine(Define.HotfixCodeEditorDir, "HotfixCode.pdb"), true); | ||
| 145 | +// | ||
| 146 | +// AssetDatabase.Refresh(); | ||
| 147 | +// Debug.Log("copy Code.dll to Bundles/Code success!"); | ||
| 148 | +// | ||
| 149 | +// Debug.Log("build success!"); | ||
| 150 | +// //反射获取当前Game视图,提示编译完成 | ||
| 151 | +// EditorNotificationHelper.ShowNotification("Build Code Success"); | ||
| 152 | +// } | ||
| 153 | +// } | ||
| 154 | +// } | ||
| 0 | \ No newline at end of file | 155 | \ No newline at end of file |
| 1 | +++ a/Editor/BuildEditor/BuildAssemblieEditor.cs.meta | ||
| @@ -0,0 +1,11 @@ | @@ -0,0 +1,11 @@ | ||
| 1 | +fileFormatVersion: 2 | ||
| 2 | +guid: db39c7b028ad96444bec9e439e89d35e | ||
| 3 | +MonoImporter: | ||
| 4 | + externalObjects: {} | ||
| 5 | + serializedVersion: 2 | ||
| 6 | + defaultReferences: [] | ||
| 7 | + executionOrder: 0 | ||
| 8 | + icon: {instanceID: 0} | ||
| 9 | + userData: | ||
| 10 | + assetBundleName: | ||
| 11 | + assetBundleVariant: |
| 1 | +++ a/Editor/BuildEditor/BuildHelper.cs | ||
| @@ -0,0 +1,276 @@ | @@ -0,0 +1,276 @@ | ||
| 1 | +// using System; | ||
| 2 | +// using System.Collections.Generic; | ||
| 3 | +// using System.IO; | ||
| 4 | +// using Sirius.Runtime; | ||
| 5 | +// using UnityEditor; | ||
| 6 | +// using UnityEditor.Build; | ||
| 7 | +// using UnityEngine; | ||
| 8 | +// using UnityGameFramework.Runtime; | ||
| 9 | +// using YooAsset.Editor; | ||
| 10 | +// | ||
| 11 | +// namespace ZhaoluGame | ||
| 12 | +// { | ||
| 13 | +// public class BuildHelper | ||
| 14 | +// { | ||
| 15 | +// static string VersionName = ""; | ||
| 16 | +// private static string PlatName = ""; | ||
| 17 | +// static string ProductName = ""; | ||
| 18 | +// private static BuildTarget BT; | ||
| 19 | +// private static int BuildVersion; | ||
| 20 | +// private static EBuildMode EBuildMode; | ||
| 21 | +// | ||
| 22 | +// public static string BuildFolder = "../Release/{0}/{1}/"; | ||
| 23 | +// | ||
| 24 | +// public static void BuildFormCammond() | ||
| 25 | +// { | ||
| 26 | +// VersionName = GetShellCmdArg("VersionName"); | ||
| 27 | +// PlatName = GetShellCmdArg("PlatName"); | ||
| 28 | +// ProductName = GetShellCmdArg("ProductName"); | ||
| 29 | +// Build(); | ||
| 30 | +// } | ||
| 31 | +// | ||
| 32 | +// [MenuItem("AA/Build_Client")] | ||
| 33 | +// public static void Build_Dev_MacOS() | ||
| 34 | +// { | ||
| 35 | +// VersionName = "Dev"; | ||
| 36 | +// PlatName = GetPlatName(); | ||
| 37 | +// ProductName = "FromSky"; | ||
| 38 | +// Build(); | ||
| 39 | +// } | ||
| 40 | +// | ||
| 41 | +// [MenuItem("AA/Release/Build_Android_Client")] | ||
| 42 | +// public static void Build_Release_Android() | ||
| 43 | +// { | ||
| 44 | +// VersionName = "Release"; | ||
| 45 | +// PlatName = "Android"; | ||
| 46 | +// ProductName = "FromSky.apk"; | ||
| 47 | +// Build(); | ||
| 48 | +// } | ||
| 49 | +// | ||
| 50 | +// public static void Build() | ||
| 51 | +// { | ||
| 52 | +// BuildTarget buildTarget = GetBuildTargetByName(PlatName); | ||
| 53 | +// | ||
| 54 | +// string fold = string.Format(BuildFolder, VersionName, PlatName); | ||
| 55 | +// if (!Directory.Exists(fold)) | ||
| 56 | +// { | ||
| 57 | +// Directory.CreateDirectory(fold); | ||
| 58 | +// } | ||
| 59 | +// | ||
| 60 | +// SetICon(VersionName); | ||
| 61 | +// | ||
| 62 | +// AssetDatabase.Refresh(); | ||
| 63 | +// | ||
| 64 | +// string[] levels = GetLevelsFromBuildSettings(); | ||
| 65 | +// Log.Info("Unity: 开始 Build Client"); | ||
| 66 | +// | ||
| 67 | +// BuildOptions buildOptions = BuildOptions.AllowDebugging | BuildOptions.ConnectWithProfiler | | ||
| 68 | +// BuildOptions.AutoRunPlayer | BuildOptions.Development | | ||
| 69 | +// BuildOptions.EnableDeepProfilingSupport; | ||
| 70 | +// | ||
| 71 | +// buildOptions = BuildOptions.None; | ||
| 72 | +// BuildPipeline.BuildPlayer(levels, $"{fold}/{ProductName}", buildTarget, buildOptions); | ||
| 73 | +// | ||
| 74 | +// Log.Info("Unity: 完成 Build Client"); | ||
| 75 | +// } | ||
| 76 | +// | ||
| 77 | +// public static void SetICon(string VersionName) | ||
| 78 | +// { | ||
| 79 | +// var texture = | ||
| 80 | +// (Texture2D) AssetDatabase.LoadAssetAtPath( | ||
| 81 | +// $"Assets/Resources/Pictures/AppIcon/AppIcon-{VersionName}.png", typeof(Texture2D)); | ||
| 82 | +// var texs = new[] {texture, texture, texture, texture, texture, texture, texture, texture}; | ||
| 83 | +// PlayerSettings.SetIcons(NamedBuildTarget.Standalone, texs, IconKind.Any); | ||
| 84 | +// } | ||
| 85 | +// | ||
| 86 | +// public static void SetBuildInfo(string vName) | ||
| 87 | +// { | ||
| 88 | +// string path = $"Assets/Resources/BuildInfo.txt"; | ||
| 89 | +// var handle = AssetDatabase.LoadAssetAtPath<TextAsset>(path); | ||
| 90 | +// var versionJson = handle.text; | ||
| 91 | +// BuildInfo buildInfo = JsonUtility.FromJson<BuildInfo>(versionJson); | ||
| 92 | +// | ||
| 93 | +// if (vName == "Dev") | ||
| 94 | +// { | ||
| 95 | +// buildInfo.AssetUrl = "http://192.168.0.109:1234"; | ||
| 96 | +// } | ||
| 97 | +// | ||
| 98 | +// if (vName == "Release") | ||
| 99 | +// { | ||
| 100 | +// buildInfo.AssetUrl = "https://formsky.oss-cn-hangzhou.aliyuncs.com"; | ||
| 101 | +// } | ||
| 102 | +// | ||
| 103 | +// var json = JsonUtility.ToJson(buildInfo); | ||
| 104 | +// | ||
| 105 | +// var filePath = Application.dataPath.Replace("Assets", path); | ||
| 106 | +// File.WriteAllText(filePath, json); | ||
| 107 | +// } | ||
| 108 | +// | ||
| 109 | +// public static void SettScriptingDefineSymbols(BuildTargetGroup btg) | ||
| 110 | +// { | ||
| 111 | +// string[] defineSymbols = | ||
| 112 | +// { | ||
| 113 | +// "NET452", | ||
| 114 | +// "THREAD_SAFE", | ||
| 115 | +// }; | ||
| 116 | +// PlayerSettings.SetScriptingDefineSymbolsForGroup(btg, defineSymbols); | ||
| 117 | +// switch (btg) | ||
| 118 | +// { | ||
| 119 | +// case BuildTargetGroup.Android: | ||
| 120 | +// EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.Android); | ||
| 121 | +// break; | ||
| 122 | +// case BuildTargetGroup.Standalone: | ||
| 123 | +// EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.StandaloneWindows64); | ||
| 124 | +// break; | ||
| 125 | +// } | ||
| 126 | +// } | ||
| 127 | +// | ||
| 128 | +// [MenuItem("Tools/Bundle Exe")] | ||
| 129 | +// public static void BundleExe() | ||
| 130 | +// { | ||
| 131 | +// var nowTarget = EditorUserBuildSettings.selectedBuildTargetGroup; | ||
| 132 | +// SettScriptingDefineSymbols(BuildTargetGroup.Standalone); | ||
| 133 | +// // BuildScript.BuildBundles(); | ||
| 134 | +// AssetDatabase.Refresh(); | ||
| 135 | +// SettScriptingDefineSymbols(nowTarget); | ||
| 136 | +// } | ||
| 137 | +// | ||
| 138 | +// [MenuItem("Tools/Bundle Apk")] | ||
| 139 | +// public static void BundleApk() | ||
| 140 | +// { | ||
| 141 | +// var nowTarget = EditorUserBuildSettings.selectedBuildTargetGroup; | ||
| 142 | +// SettScriptingDefineSymbols(BuildTargetGroup.Android); | ||
| 143 | +// | ||
| 144 | +// AssetDatabase.Refresh(); | ||
| 145 | +// | ||
| 146 | +// // BuildScript.BuildBundles(); | ||
| 147 | +// | ||
| 148 | +// AssetDatabase.Refresh(); | ||
| 149 | +// SettScriptingDefineSymbols(nowTarget); | ||
| 150 | +// } | ||
| 151 | +// | ||
| 152 | +// [MenuItem("Tools/DefineSymbols")] | ||
| 153 | +// public static void SettScriptingDefineSymbolsPc() | ||
| 154 | +// { | ||
| 155 | +// SettScriptingDefineSymbols(EditorUserBuildSettings.selectedBuildTargetGroup); | ||
| 156 | +// } | ||
| 157 | +// | ||
| 158 | +// public static string[] GetLevelsFromBuildSettings() | ||
| 159 | +// { | ||
| 160 | +// List<string> scenes = new List<string>(); | ||
| 161 | +// scenes.Add("Assets/GameMain/Scenes/Entry.unity"); | ||
| 162 | +// scenes.Add("Assets/GameMain/Scenes/PreScene.unity"); | ||
| 163 | +// scenes.Add("Assets/GameMain/Scenes/MainScene.unity"); | ||
| 164 | +// scenes.Add("Assets/GameMain/Scenes/Battle/00_test.unity"); | ||
| 165 | +// scenes.Add("Assets/GameMain/Scenes/Battle/01_test.unity"); | ||
| 166 | +// scenes.Add("Assets/GameMain/Scenes/Battle/1.unity"); | ||
| 167 | +// scenes.Add("Assets/GameMain/Scenes/Battle/2.unity"); | ||
| 168 | +// scenes.Add("Assets/GameMain/Scenes/Battle/3.unity"); | ||
| 169 | +// scenes.Add("Assets/GameMain/Scenes/Battle/4.unity"); | ||
| 170 | +// scenes.Add("Assets/GameMain/Scenes/Battle/5.unity"); | ||
| 171 | +// scenes.Add("Assets/GameMain/Scenes/Battle/6.unity"); | ||
| 172 | +// scenes.Add("Assets/GameMain/Scenes/Battle/7.unity"); | ||
| 173 | +// scenes.Add("Assets/GameMain/Scenes/Battle/8.unity"); | ||
| 174 | +// scenes.Add("Assets/GameMain/Scenes/Battle/9.unity"); | ||
| 175 | +// scenes.Add("Assets/GameMain/Scenes/Battle/10.unity"); | ||
| 176 | +// return scenes.ToArray(); | ||
| 177 | +// } | ||
| 178 | +// | ||
| 179 | +// public static string GetShellCmdArg(string argName) | ||
| 180 | +// { | ||
| 181 | +// { | ||
| 182 | +// #if UNITY_EDITOR | ||
| 183 | +// //在这里分析shell传入的参数, 还记得上面我们说的哪个 project-$1 这个参数吗? | ||
| 184 | +// //这里遍历所有参数,找到 project开头的参数, 然后把-符号 后面的字符串返回, | ||
| 185 | +// foreach (string arg in System.Environment.GetCommandLineArgs()) | ||
| 186 | +// { | ||
| 187 | +// if (arg.StartsWith(argName)) | ||
| 188 | +// { | ||
| 189 | +// return arg.Split("="[0])[1]; | ||
| 190 | +// } | ||
| 191 | +// } | ||
| 192 | +// #endif | ||
| 193 | +// } | ||
| 194 | +// Debug.LogError($"这个参数未输入! {argName}"); | ||
| 195 | +// return ""; | ||
| 196 | +// } | ||
| 197 | +// | ||
| 198 | +// public static BuildTarget GetBuildTargetByName(string plat) | ||
| 199 | +// { | ||
| 200 | +// BuildTarget buildTarget = BuildTarget.StandaloneOSX; | ||
| 201 | +// if (plat == "MacOS") | ||
| 202 | +// { | ||
| 203 | +// buildTarget = BuildTarget.StandaloneOSX; | ||
| 204 | +// } | ||
| 205 | +// else if (plat == "Win") | ||
| 206 | +// { | ||
| 207 | +// buildTarget = BuildTarget.StandaloneWindows64; | ||
| 208 | +// } | ||
| 209 | +// else if (plat == "Android") | ||
| 210 | +// { | ||
| 211 | +// buildTarget = BuildTarget.Android; | ||
| 212 | +// } | ||
| 213 | +// | ||
| 214 | +// return buildTarget; | ||
| 215 | +// } | ||
| 216 | +// | ||
| 217 | +// public static string GetPlatName() | ||
| 218 | +// { | ||
| 219 | +// if (Environment.OSVersion.Platform == PlatformID.Unix) | ||
| 220 | +// { | ||
| 221 | +// PlatName = "MacOS"; | ||
| 222 | +// } | ||
| 223 | +// else | ||
| 224 | +// { | ||
| 225 | +// PlatName = "Win"; | ||
| 226 | +// } | ||
| 227 | +// return PlatName; | ||
| 228 | +// } | ||
| 229 | +// | ||
| 230 | +// public static void BuildYooAssetFromCommand() | ||
| 231 | +// { | ||
| 232 | +// var BuildTargetStr = GetShellCmdArg("BuildTarget"); | ||
| 233 | +// if (BuildTargetStr == "Android") | ||
| 234 | +// BT = BuildTarget.Android; | ||
| 235 | +// | ||
| 236 | +// var BuildVersionStr = GetShellCmdArg("BuildVersion"); | ||
| 237 | +// int.TryParse(BuildVersionStr, out BuildVersion); | ||
| 238 | +// | ||
| 239 | +// var EBuildModeStr = GetShellCmdArg("EBuildMode"); | ||
| 240 | +// if (EBuildModeStr == EBuildMode.ForceRebuild.ToString()) | ||
| 241 | +// EBuildMode = EBuildMode.ForceRebuild; | ||
| 242 | +// if (EBuildModeStr == EBuildMode.IncrementalBuild.ToString()) | ||
| 243 | +// EBuildMode = EBuildMode.IncrementalBuild; | ||
| 244 | +// | ||
| 245 | +// BuildYooAssetInternel(); | ||
| 246 | +// } | ||
| 247 | +// | ||
| 248 | +// [MenuItem("Tools/BuildYooAsset")] | ||
| 249 | +// public static void BuildYooAssetInternel() | ||
| 250 | +// { | ||
| 251 | +// Debug.Log($"开始构建"); | ||
| 252 | +// | ||
| 253 | +// // 构建参数 | ||
| 254 | +// string projectPath = EditorTools.GetProjectPath(); | ||
| 255 | +// string defaultOutputRoot = $"{projectPath}/../../blackcat-update"; | ||
| 256 | +// BuildParameters buildParameters = new BuildParameters(); | ||
| 257 | +// buildParameters.OutputRoot = defaultOutputRoot; | ||
| 258 | +// buildParameters.BuildTarget = BT; | ||
| 259 | +// buildParameters.BuildMode = EBuildMode; | ||
| 260 | +// buildParameters.BuildVersion = BuildVersion; | ||
| 261 | +// buildParameters.BuildinTags = "buildin"; | ||
| 262 | +// buildParameters.VerifyBuildingResult = true; | ||
| 263 | +// buildParameters.EnableAddressable = true; | ||
| 264 | +// buildParameters.AppendFileExtension = false; | ||
| 265 | +// buildParameters.CopyBuildinTagFiles = true; | ||
| 266 | +// buildParameters.EncryptionServices = new GameEncryption(); | ||
| 267 | +// buildParameters.CompressOption = ECompressOption.LZ4; | ||
| 268 | +// | ||
| 269 | +// // 执行构建 | ||
| 270 | +// AssetBundleBuilder builder = new AssetBundleBuilder(); | ||
| 271 | +// builder.Run(buildParameters); | ||
| 272 | +// | ||
| 273 | +// Debug.Log($"构建完成"); | ||
| 274 | +// } | ||
| 275 | +// } | ||
| 276 | +// } | ||
| 0 | \ No newline at end of file | 277 | \ No newline at end of file |
| 1 | +++ a/Editor/BuildEditor/BuildHelper.cs.meta | ||
| @@ -0,0 +1,11 @@ | @@ -0,0 +1,11 @@ | ||
| 1 | +fileFormatVersion: 2 | ||
| 2 | +guid: 12ef427a1149a4a599dbfc95b31d2850 | ||
| 3 | +MonoImporter: | ||
| 4 | + externalObjects: {} | ||
| 5 | + serializedVersion: 2 | ||
| 6 | + defaultReferences: [] | ||
| 7 | + executionOrder: 0 | ||
| 8 | + icon: {instanceID: 0} | ||
| 9 | + userData: | ||
| 10 | + assetBundleName: | ||
| 11 | + assetBundleVariant: |
| 1 | +++ a/Editor/BuildEditor/EditorNotificationHelper.cs | ||
| @@ -0,0 +1,65 @@ | @@ -0,0 +1,65 @@ | ||
| 1 | +// ----------------------------------------------- | ||
| 2 | +// Copyright © Sirius. All rights reserved. | ||
| 3 | +// CreateTime: 2022/6/7 14:35:16 | ||
| 4 | +// ----------------------------------------------- | ||
| 5 | + | ||
| 6 | +#if UNITY_EDITOR | ||
| 7 | +using UnityEditor; | ||
| 8 | +using UnityEngine; | ||
| 9 | + | ||
| 10 | +namespace ZhaoluGame | ||
| 11 | +{ | ||
| 12 | + public static class EditorNotificationHelper | ||
| 13 | + { | ||
| 14 | + public static void ShowNotification(string tips) | ||
| 15 | + { | ||
| 16 | + var game = EditorWindow.GetWindow(typeof(EditorWindow).Assembly.GetType("UnityEditor.GameView")); | ||
| 17 | + game?.ShowNotification(new GUIContent($"{tips}")); | ||
| 18 | + } | ||
| 19 | + } | ||
| 20 | + [InitializeOnLoad] | ||
| 21 | + public class EditorNotification : AssetPostprocessor | ||
| 22 | + { | ||
| 23 | + private static bool isFocused; | ||
| 24 | + static EditorNotification() | ||
| 25 | + { | ||
| 26 | + EditorApplication.update += Update; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + private static void Update() | ||
| 30 | + { | ||
| 31 | + if (isFocused == UnityEditorInternal.InternalEditorUtility.isApplicationActive) | ||
| 32 | + { | ||
| 33 | + return; | ||
| 34 | + } | ||
| 35 | + isFocused = UnityEditorInternal.InternalEditorUtility.isApplicationActive; | ||
| 36 | + OnEditorFocus(isFocused); | ||
| 37 | + } | ||
| 38 | + /// <summary> | ||
| 39 | + /// Unity���ھ۽�״̬�ı�ص� | ||
| 40 | + /// </summary> | ||
| 41 | + /// <param name="focus"></param> | ||
| 42 | + private static void OnEditorFocus(bool focus) | ||
| 43 | + { | ||
| 44 | + if (focus) | ||
| 45 | + { | ||
| 46 | + //ÿ���л���Unity���Զ�ִ�нű����� | ||
| 47 | + // Debug.Log($"�༭������״̬:{focus}"); | ||
| 48 | + bool autoBuild = PlayerPrefs.HasKey("AutoBuild"); | ||
| 49 | + if (!autoBuild) | ||
| 50 | + return; | ||
| 51 | + // BuildAssemblieEditor.BuildCodeDebug(); | ||
| 52 | + } | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + /// <summary> | ||
| 56 | + /// Asset���ļ��ı�ʱ�ص� | ||
| 57 | + /// </summary> | ||
| 58 | + private void OnPreprocessAsset() | ||
| 59 | + { | ||
| 60 | + //Debug.Log("Asset���ļ��ı�ʱ�ص�"); | ||
| 61 | + } | ||
| 62 | + } | ||
| 63 | +} | ||
| 64 | + | ||
| 65 | +#endif |
Editor/BuildEditor/EditorNotificationHelper.cs.meta
0 → 100644
| 1 | +++ a/Editor/BuildEditor/EditorNotificationHelper.cs.meta | ||
| @@ -0,0 +1,11 @@ | @@ -0,0 +1,11 @@ | ||
| 1 | +fileFormatVersion: 2 | ||
| 2 | +guid: 97026fb4c18b947d6af149be86c1d41f | ||
| 3 | +MonoImporter: | ||
| 4 | + externalObjects: {} | ||
| 5 | + serializedVersion: 2 | ||
| 6 | + defaultReferences: [] | ||
| 7 | + executionOrder: 0 | ||
| 8 | + icon: {instanceID: 0} | ||
| 9 | + userData: | ||
| 10 | + assetBundleName: | ||
| 11 | + assetBundleVariant: |
| 1 | +++ a/Editor/ZhaoluEditor.asmdef | ||
| @@ -0,0 +1,19 @@ | @@ -0,0 +1,19 @@ | ||
| 1 | +{ | ||
| 2 | + "name": "ZhaoluEditor", | ||
| 3 | + "rootNamespace": "", | ||
| 4 | + "references": [ | ||
| 5 | + "GUID:4d1926c9df5b052469a1c63448b7609a", | ||
| 6 | + "GUID:4bd03dfaaadd6453e8ca3a932709f626" | ||
| 7 | + ], | ||
| 8 | + "includePlatforms": [ | ||
| 9 | + "Editor" | ||
| 10 | + ], | ||
| 11 | + "excludePlatforms": [], | ||
| 12 | + "allowUnsafeCode": false, | ||
| 13 | + "overrideReferences": false, | ||
| 14 | + "precompiledReferences": [], | ||
| 15 | + "autoReferenced": true, | ||
| 16 | + "defineConstraints": [], | ||
| 17 | + "versionDefines": [], | ||
| 18 | + "noEngineReferences": false | ||
| 19 | +} | ||
| 0 | \ No newline at end of file | 20 | \ No newline at end of file |
| 1 | +++ a/Editor/ZhaoluEditor.cs | ||
| @@ -0,0 +1,94 @@ | @@ -0,0 +1,94 @@ | ||
| 1 | +// ----------------------------------------------- | ||
| 2 | +// Copyright © Sirius. All rights reserved. | ||
| 3 | +// CreateTime: 2022/4/28 12:4:42 | ||
| 4 | +// ----------------------------------------------- | ||
| 5 | +// ----------------------------------------------- | ||
| 6 | +// Copyright © Sirius. All rights reserved. | ||
| 7 | +// CreateTime: 2022/4/24 17:1:7 | ||
| 8 | +// ----------------------------------------------- | ||
| 9 | + | ||
| 10 | +#if UNITY_EDITOR | ||
| 11 | + | ||
| 12 | +using System; | ||
| 13 | +using UnityEditor; | ||
| 14 | +using UnityEngine; | ||
| 15 | + | ||
| 16 | +public class ZhaoluEditor | ||
| 17 | +{ | ||
| 18 | + public static string path = $"{Application.dataPath}/../../Tools/"; | ||
| 19 | + | ||
| 20 | + [MenuItem("Zhaolu/Luban Export")] | ||
| 21 | + private static void LubanExport() | ||
| 22 | + { | ||
| 23 | +#if UNITY_EDITOR_OSX | ||
| 24 | + string ShellPath = $"{Application.dataPath}/../../Tools/ShellCommands"; | ||
| 25 | + ShellHelper.Run("sh Git/UpdateLuban.sh", ShellPath); | ||
| 26 | +#endif | ||
| 27 | + path = $"{Application.dataPath}/../../Tools/Luban"; | ||
| 28 | + Debug.Log(path); | ||
| 29 | +#if UNITY_EDITOR_OSX | ||
| 30 | + ShellHelper.Run("sh gen_code_bin.sh", path); | ||
| 31 | +#elif UNITY_EDITOR_WIN | ||
| 32 | + ShellHelper.Run("gen_code_bin_ForUnity.bat", path); | ||
| 33 | +#endif | ||
| 34 | + AssetDatabase.Refresh(); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + [MenuItem("Zhaolu/Luban Clean Gen")] | ||
| 38 | + private static void LubanCleanGen() | ||
| 39 | + { | ||
| 40 | + | ||
| 41 | +#if UNITY_EDITOR_OSX | ||
| 42 | + path = $"{Application.dataPath}/../../Tools/ShellCommands"; | ||
| 43 | + ShellHelper.Run("sh Git/CheckoutGenerate_Luban.sh", path); | ||
| 44 | + return; | ||
| 45 | +#endif | ||
| 46 | + try | ||
| 47 | + { | ||
| 48 | + ShellHelper.Run("CheckoutGenerate_Luban.bat", path); | ||
| 49 | + } | ||
| 50 | + catch (Exception e) | ||
| 51 | + { | ||
| 52 | + Console.WriteLine(e); | ||
| 53 | + throw; | ||
| 54 | + } | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + [MenuItem("Zhaolu/Proto Export")] | ||
| 58 | + private static void ProtoExport() | ||
| 59 | + { | ||
| 60 | +#if UNITY_EDITOR_OSX | ||
| 61 | + path = $"{Application.dataPath}/../../Tools/ShellCommands"; | ||
| 62 | + ShellHelper.Run("sh Git/UpdateProto.sh", path); | ||
| 63 | + return; | ||
| 64 | +#endif | ||
| 65 | + path = $"{Application.dataPath}/../../Tools/Tools/bin/Debug/net6.0"; | ||
| 66 | + ShellHelper.Run("dotnet Tools.dll", path); | ||
| 67 | + AssetDatabase.Refresh(); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + [MenuItem("Zhaolu/Proto Clean Gen")] | ||
| 71 | + private static void ProtoCleanGen() | ||
| 72 | + { | ||
| 73 | +#if UNITY_EDITOR_OSX | ||
| 74 | + path = $"{Application.dataPath}/../../Tools/ShellCommands"; | ||
| 75 | + ShellHelper.Run("sh Git/CheckoutGenerate_Proto.sh", path); | ||
| 76 | + return; | ||
| 77 | +#endif | ||
| 78 | + ShellHelper.Run("CheckoutGenerate_Proto.bat", path); | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + | ||
| 82 | + [MenuItem("Zhaolu/FGUI Clean Gen")] | ||
| 83 | + private static void FGUICleanGen() | ||
| 84 | + { | ||
| 85 | +#if UNITY_EDITOR_OSX | ||
| 86 | + path = $"{Application.dataPath}/../../Tools/ShellCommands"; | ||
| 87 | + ShellHelper.Run("sh Git/CheckoutGenerate_Fui.sh", path); | ||
| 88 | + return; | ||
| 89 | +#endif | ||
| 90 | + ShellHelper.Run("CheckoutGenerate_Fui.bat", path); | ||
| 91 | + } | ||
| 92 | +} | ||
| 93 | + | ||
| 94 | +#endif | ||
| 0 | \ No newline at end of file | 95 | \ No newline at end of file |
| 1 | +++ a/Editor/ZhaoluEditor.cs.meta | ||
| @@ -0,0 +1,11 @@ | @@ -0,0 +1,11 @@ | ||
| 1 | +fileFormatVersion: 2 | ||
| 2 | +guid: dcc70e3c41bdc479b94bdb422d77d537 | ||
| 3 | +MonoImporter: | ||
| 4 | + externalObjects: {} | ||
| 5 | + serializedVersion: 2 | ||
| 6 | + defaultReferences: [] | ||
| 7 | + executionOrder: 0 | ||
| 8 | + icon: {instanceID: 0} | ||
| 9 | + userData: | ||
| 10 | + assetBundleName: | ||
| 11 | + assetBundleVariant: |