diff --git a/.gitignore b/.gitignore index 199db19..d72626b 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,4 @@ Temp/ Library/ UserSettings/ obj/ - +output/ diff --git a/Assets/VersionFlow/Builder/Builder.asset b/Assets/VersionFlow/Builder/Builder.asset index 7d1a955..8f56d9b 100644 --- a/Assets/VersionFlow/Builder/Builder.asset +++ b/Assets/VersionFlow/Builder/Builder.asset @@ -13,10 +13,16 @@ MonoBehaviour: m_Name: Builder m_EditorClassIdentifier: vfSetting: {fileID: 11400000, guid: b304f98f44ccac546969282b7054a052, type: 2} - uploaderClassName: VersionFlow.Editors.Patchloader_AliOSS - uploaderCfgJson: '{"BucketName":"2020yoyo","UploadPath":"VERSION_TEST","accessKeyId":"LTAI5tCMR4e8A4W8sKvt1pLe","accessKeySecret":"yOGzDbtS1cGS9y5C7akfjgITf376CJ","endPoint":"oss-cn-hangzhou.aliyuncs.com"}' + uploaderClassName: VersionFlow.Editors.PatchUploader_LocalFileSystem + uploaderCfgJson: '{"UploadRoot":"../TestDown"}' Options: 256 - Groups: [] + Groups: + - GroupName: Effect + BuildMode: 2 + OptionBundle: 0 + InstallReady: 0 + FolderList: + - {fileID: 102900000, guid: 575569e40b6a7d847aeed7e74c5fead8, type: 3} SVC: {fileID: 0} DuplicateBundleBeInstallBundle: 0 ShaderBundleBeInstallBundle: 0 diff --git a/Assets/VersionFlow/Editor/BuilderConfigEditor.cs b/Assets/VersionFlow/Editor/BuilderConfigEditor.cs index aac5a05..2e43d43 100644 --- a/Assets/VersionFlow/Editor/BuilderConfigEditor.cs +++ b/Assets/VersionFlow/Editor/BuilderConfigEditor.cs @@ -1,5 +1,4 @@ -using Aliyun.OSS; -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -7,7 +6,6 @@ using System.Text; using UnityEditor; using UnityEngine; using VersionFlow.Runtime; -using static UnityEditor.ObjectChangeEventStream; namespace VersionFlow.Editors { @@ -95,11 +93,11 @@ namespace VersionFlow.Editors var uploaderTypes = builder.GetAllPatcherType(); var options = uploaderTypes.Select(t => $"{t.Namespace}.{t.Name}").ToList(); - + var selectIndex = options.IndexOf(builder.uploaderClassName); - selectIndex = EditorGUILayout.Popup("选择上传器", selectIndex, options.Select(op=>PatchUploaderUtility.GetPatcherPrettyName(op)).ToArray()); + selectIndex = EditorGUILayout.Popup("选择上传器", selectIndex, options.Select(op => PatchUploaderUtility.GetPatcherPrettyName(op)).ToArray()); if (selectIndex != -1) { var selectClassName = options[selectIndex]; diff --git a/Assets/VersionFlow/Editor/CDNTaskWindow.cs b/Assets/VersionFlow/Editor/CDNTaskWindow.cs index dd6171f..d13a5ac 100644 --- a/Assets/VersionFlow/Editor/CDNTaskWindow.cs +++ b/Assets/VersionFlow/Editor/CDNTaskWindow.cs @@ -1,16 +1,14 @@ -using AlibabaCloud.SDK.Cdn20180510.Models; -using System.Collections.Generic; +using System.Collections.Generic; using System.Threading.Tasks; using UnityEditor; using UnityEngine; -using VersionFlow.Runtime; using static VersionFlow.Editors.ICDNPerformer; namespace VersionFlow.Editors.Assets.Scripts.VersionFlow.Editor { public class CDNTaskWindow : EditorWindow { - [MenuItem("项目工具/Builder/CDN进度查询")] + [MenuItem("VersionFlow/CDN进度查询")] public static void OpenWindow() { var window = GetWindow(); diff --git a/Assets/VersionFlow/Editor/LoadingChainGraph/LoadingChainDebugWindow.cs b/Assets/VersionFlow/Editor/LoadingChainGraph/LoadingChainDebugWindow.cs index 5ffd805..1aa72a5 100644 --- a/Assets/VersionFlow/Editor/LoadingChainGraph/LoadingChainDebugWindow.cs +++ b/Assets/VersionFlow/Editor/LoadingChainGraph/LoadingChainDebugWindow.cs @@ -5,7 +5,7 @@ namespace VersionFlow.Editors { public class LoadingChainDebugWindow : EditorWindow { - [MenuItem("Tools/VersionFlow/Debug")] + [MenuItem("VersionFlow/RuntimeDebug")] public static void Open() { var wnd = GetWindow(); diff --git a/Assets/VersionFlow/Editor/PatchUploader/PatchUploader.cs b/Assets/VersionFlow/Editor/PatchUploader/PatchUploader.cs index b2621f5..2a59e75 100644 --- a/Assets/VersionFlow/Editor/PatchUploader/PatchUploader.cs +++ b/Assets/VersionFlow/Editor/PatchUploader/PatchUploader.cs @@ -11,7 +11,7 @@ namespace VersionFlow.Editors public abstract void CfgChanged(BuilderConfig builder, string cfgJson); public abstract void UploadFile(string remoteFilePath, MemoryStream localfileStream); public abstract byte[] DownloadFile(string remoteFilePath); - public abstract void DeleteFile(string bundlePath); + public abstract void DeleteFile(string remoteFilePath); public abstract string GetCfgJson(); } diff --git a/Assets/VersionFlow/Editor/PatchUploader/PatchUploaderImpl/PatchUpLoader_AliOSS.cs b/Assets/VersionFlow/Editor/PatchUploader/PatchUploaderImpl/PatchUpLoader_AliOSS.cs index 6be5b7c..1cab87f 100644 --- a/Assets/VersionFlow/Editor/PatchUploader/PatchUploaderImpl/PatchUpLoader_AliOSS.cs +++ b/Assets/VersionFlow/Editor/PatchUploader/PatchUploaderImpl/PatchUpLoader_AliOSS.cs @@ -41,9 +41,9 @@ namespace VersionFlow.Editors m_ossClient.PutObject(m_cfg.BucketName, filePathInBucket, localfileStream, metadata); } - public override void DeleteFile(string bundlePath) + public override void DeleteFile(string remoteFilePath) { - m_ossClient.DeleteObject(m_cfg.BucketName, bundlePath); + m_ossClient.DeleteObject(m_cfg.BucketName, remoteFilePath); } void ICDNPerformer.CDNRefresh(IEnumerable refreshPaths) diff --git a/Assets/VersionFlow/Editor/PatchUploader/PatchUploaderImpl/PatchUploader_LocalFileSystem.cs b/Assets/VersionFlow/Editor/PatchUploader/PatchUploaderImpl/PatchUploader_LocalFileSystem.cs new file mode 100644 index 0000000..896ddd0 --- /dev/null +++ b/Assets/VersionFlow/Editor/PatchUploader/PatchUploaderImpl/PatchUploader_LocalFileSystem.cs @@ -0,0 +1,47 @@ +using System; +using System.ComponentModel; +using System.IO; + +namespace VersionFlow.Editors +{ + [Description("本地文件系统")] + public class PatchUploader_LocalFileSystem : PatchUploader + { + protected override void OnCfgChanged() { } + + public override void UploadFile(string remoteFilePath, MemoryStream localfileStream) + { + var writePath = $"{m_cfg.UploadRoot}/{remoteFilePath}"; + var direct = Path.GetDirectoryName(writePath); + Directory.CreateDirectory(direct); + + File.WriteAllBytes(writePath, localfileStream.ToArray()); + } + + public override byte[] DownloadFile(string remoteFilePath) + { + try + { + return File.ReadAllBytes($"{m_cfg.UploadRoot}/{remoteFilePath}"); + } + catch + { + return null; + } + } + + public override void DeleteFile(string remoteFilePath) + { + var path = $"{m_cfg.UploadRoot}/{remoteFilePath}"; + + if (File.Exists(path)) + File.Delete(path); + } + + [Serializable] + public struct Config + { + public string UploadRoot; + } + } +} \ No newline at end of file diff --git a/Assets/VersionFlow/Editor/PatchUploader/PatchUploaderImpl/PatchUploader_LocalFileSystem.cs.meta b/Assets/VersionFlow/Editor/PatchUploader/PatchUploaderImpl/PatchUploader_LocalFileSystem.cs.meta new file mode 100644 index 0000000..c03e652 --- /dev/null +++ b/Assets/VersionFlow/Editor/PatchUploader/PatchUploaderImpl/PatchUploader_LocalFileSystem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 056e6292c75f09242a261ec6d965487c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VersionFlow/Editor/PatchUploader/PatchUploaderUtility.cs b/Assets/VersionFlow/Editor/PatchUploader/PatchUploaderUtility.cs index 73ebad4..841b6c4 100644 --- a/Assets/VersionFlow/Editor/PatchUploader/PatchUploaderUtility.cs +++ b/Assets/VersionFlow/Editor/PatchUploader/PatchUploaderUtility.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Reflection; using UnityEditor; +using UnityEngine; using VersionFlow.Runtime; namespace VersionFlow.Editors @@ -28,14 +29,12 @@ namespace VersionFlow.Editors if (!typeof(PatchUploader).IsAssignableFrom(type)) continue; s_patchloaderTypesMapper[type.FullName] = type; + var desAttName = $"{type.Namespace}.{type.Name}"; if (type.GetCustomAttribute() is DescriptionAttribute desAtt) { - s_patcherPrettyNameMapper[type] = desAtt.Description; - } - else - { - s_patcherPrettyNameMapper[type] = $"{type.Namespace}.{type.Name}"; + desAttName = desAtt.Description; } + s_patcherPrettyNameMapper[type] = desAttName; } } } @@ -80,7 +79,7 @@ namespace VersionFlow.Editors } else //创建patchloader实例 { - var patchloaderInstance = Activator.CreateInstance(patchType) as PatchUploader; + var patchloaderInstance = ScriptableObject.CreateInstance(patchType) as PatchUploader; patchloaderInstance.CfgChanged(builder, builder.uploaderCfgJson); s_patchInstance[builder] = patchloaderInstance; return patchloaderInstance; diff --git a/Assets/VersionFlow/Editor/VersionFlowSettingEditor.cs b/Assets/VersionFlow/Editor/VersionFlowSettingEditor.cs index 12f0126..47de230 100644 --- a/Assets/VersionFlow/Editor/VersionFlowSettingEditor.cs +++ b/Assets/VersionFlow/Editor/VersionFlowSettingEditor.cs @@ -1,6 +1,4 @@ -using System; -using System.Linq; -using System.Reflection; +using System.Linq; using UnityEditor; using UnityEngine; using VersionFlow.Runtime; @@ -10,34 +8,6 @@ namespace VersionFlow.Editors [CustomEditor(typeof(VersionFlowSetting))] public class VersionFlowSettingEditor : Editor { - [MenuItem("项目工具/打开VersionFlow设置 &4")] - public static void OpenSettingInspector() - { - var setting = AssetDatabase.LoadAssetAtPath("Assets/Scripts/VersionFlow/Resources/VersionFlowSettings.asset"); - var builder = AssetDatabase.LoadAssetAtPath("Assets/Scripts/VersionFlow/Builder/Builder.asset"); - - EditorApplication.delayCall += () => - { - OpenPropertyEditor(setting); - EditorApplication.delayCall += () => - { - OpenPropertyEditor(builder); - }; - }; - } - - - public static dynamic OpenPropertyEditor(UnityEngine.Object obj, bool showWindow = true) - { - var ass = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(ass => ass.FullName.Contains("UnityEditor.CoreModule")); - if (ass == null) return null; - - var t = ass.GetType("UnityEditor.PropertyEditor"); - Type[] parameterTypes = { typeof(UnityEngine.Object), typeof(bool) }; - var method = t.GetMethod("OpenPropertyEditor", BindingFlags.Static | BindingFlags.NonPublic, null, parameterTypes, null); - return method.Invoke(null, new object[] { obj, showWindow }); - } - private bool foldBundleLoadingInfo; private bool foldOptionDownloader; public override void OnInspectorGUI() diff --git a/Assets/VersionFlow/Editor/VersionFlowSettingWnd.cs b/Assets/VersionFlow/Editor/VersionFlowSettingWnd.cs new file mode 100644 index 0000000..ca5fd5c --- /dev/null +++ b/Assets/VersionFlow/Editor/VersionFlowSettingWnd.cs @@ -0,0 +1,54 @@ +using UnityEditor; +using UnityEngine; +using VersionFlow.Runtime; + +namespace VersionFlow.Editors +{ + public class VersionFlowSettingWnd : EditorWindow + { + private BuilderConfig m_builder; + private Editor m_builderEditor; + private Editor m_settingEditor; + private Vector2 m_builderEditorScroll; + + [MenuItem("VersionFlow/Setting")] + static void Open() + { + var wnd = EditorWindow.GetWindow(); + wnd.Show(); + } + + private void OnEnable() + { + m_builder = PatchUploaderUtility.FindBuilderInProject(); + + m_builderEditor = Editor.CreateEditor(m_builder); + m_settingEditor = Editor.CreateEditor(m_builder.vfSetting); + + m_currentEditor = m_builderEditor; + } + + Editor m_currentEditor; + private void OnGUI() + { + EditorGUILayout.BeginHorizontal(); + if (GUILayout.Toggle(m_currentEditor == m_builderEditor, "上传设置", GUI.skin.button)) + { + m_currentEditor = m_builderEditor; + } + if (GUILayout.Toggle(m_currentEditor == m_settingEditor, "运行时设置", GUI.skin.button)) + { + m_currentEditor = m_settingEditor; + } + EditorGUILayout.EndVertical(); + + EditorGUILayout.BeginVertical(EditorStyles.helpBox); + { + m_builderEditorScroll = EditorGUILayout.BeginScrollView(m_builderEditorScroll); + m_currentEditor.OnInspectorGUI(); + EditorGUILayout.EndScrollView(); + } + EditorGUILayout.EndVertical(); + } + } +} \ No newline at end of file diff --git a/Assets/VersionFlow/Editor/VersionFlowSettingWnd.cs.meta b/Assets/VersionFlow/Editor/VersionFlowSettingWnd.cs.meta new file mode 100644 index 0000000..ba479dc --- /dev/null +++ b/Assets/VersionFlow/Editor/VersionFlowSettingWnd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 29eb4093954b5384086d1b51782f4ba3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VersionFlow/Resources/VersionFlowSettings.asset b/Assets/VersionFlow/Resources/VersionFlowSettings.asset index b0a177b..f9a53c5 100644 --- a/Assets/VersionFlow/Resources/VersionFlowSettings.asset +++ b/Assets/VersionFlow/Resources/VersionFlowSettings.asset @@ -12,7 +12,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 7dc52158fc454554abe766cf83fc6e1b, type: 3} m_Name: VersionFlowSettings m_EditorClassIdentifier: - PendingPatch: PendingPatch_ORG - RootPath: https://update.2020yoyo.com - SubPath: HXORG + RootPath: https://update.test.com + SubPath: ProjectName AutoReleaseBundle: 1 diff --git a/Assets/VersionFlow/Runtime/VersionFlowSetting.cs b/Assets/VersionFlow/Runtime/VersionFlowSetting.cs index a6529cb..5c3132e 100644 --- a/Assets/VersionFlow/Runtime/VersionFlowSetting.cs +++ b/Assets/VersionFlow/Runtime/VersionFlowSetting.cs @@ -12,12 +12,10 @@ namespace VersionFlow.Runtime get => EditorPrefs.GetBool("VERSIONFLOW_ENABLE_IN_EDITOR", false); set => EditorPrefs.SetBool("VERSIONFLOW_ENABLE_IN_EDITOR", value); } - - public string PendingPatch = "PendingPatch_ORG"; #endif - public string RootPath = "https://download-test.hx160.com"; - public string SubPath = "hx3_new_test"; + public string RootPath = "https://127.0.0.1:80"; + public string SubPath = "ProjectName"; /// 自动释放Bundle资源 public bool AutoReleaseBundle;