From 449ee2f1941405e7ee792d1d719b13836282a0a0 Mon Sep 17 00:00:00 2001 From: Lillith Rose Date: Sun, 5 Oct 2025 21:17:34 -0400 Subject: [PATCH] link downloader --- LinkDownloader.meta | 8 ++++ LinkDownloader/Editor.meta | 8 ++++ .../Editor/LinkDownloaderEditor.asmdef | 19 +++++++++ .../Editor/LinkDownloaderEditor.asmdef.meta | 7 ++++ LinkDownloader/Editor/LinkDownloaderPlugin.cs | 41 +++++++++++++++++++ .../Editor/LinkDownloaderPlugin.cs.meta | 11 +++++ LinkDownloader/Runtime.meta | 8 ++++ .../Runtime/LinkDownloaderConfig.cs | 12 ++++++ .../Runtime/LinkDownloaderConfig.cs.meta | 11 +++++ .../Runtime/LinkDownloaderRuntime.asmdef | 14 +++++++ .../Runtime/LinkDownloaderRuntime.asmdef.meta | 7 ++++ 11 files changed, 146 insertions(+) create mode 100644 LinkDownloader.meta create mode 100644 LinkDownloader/Editor.meta create mode 100644 LinkDownloader/Editor/LinkDownloaderEditor.asmdef create mode 100644 LinkDownloader/Editor/LinkDownloaderEditor.asmdef.meta create mode 100644 LinkDownloader/Editor/LinkDownloaderPlugin.cs create mode 100644 LinkDownloader/Editor/LinkDownloaderPlugin.cs.meta create mode 100644 LinkDownloader/Runtime.meta create mode 100644 LinkDownloader/Runtime/LinkDownloaderConfig.cs create mode 100644 LinkDownloader/Runtime/LinkDownloaderConfig.cs.meta create mode 100644 LinkDownloader/Runtime/LinkDownloaderRuntime.asmdef create mode 100644 LinkDownloader/Runtime/LinkDownloaderRuntime.asmdef.meta diff --git a/LinkDownloader.meta b/LinkDownloader.meta new file mode 100644 index 0000000..08255ce --- /dev/null +++ b/LinkDownloader.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6faa76d34adb0ca48bcf418bccf1149b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/LinkDownloader/Editor.meta b/LinkDownloader/Editor.meta new file mode 100644 index 0000000..3716997 --- /dev/null +++ b/LinkDownloader/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6c117da7fe8d0604ca33a833223beebe +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/LinkDownloader/Editor/LinkDownloaderEditor.asmdef b/LinkDownloader/Editor/LinkDownloaderEditor.asmdef new file mode 100644 index 0000000..e29428f --- /dev/null +++ b/LinkDownloader/Editor/LinkDownloaderEditor.asmdef @@ -0,0 +1,19 @@ +{ + "name": "LinkDownloaderEditor", + "rootNamespace": "", + "references": [ + "GUID:f7a3c1e913875bf4896e48f991fdd5a6", + "GUID:62ced99b048af7f4d8dfe4bed8373d76" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/LinkDownloader/Editor/LinkDownloaderEditor.asmdef.meta b/LinkDownloader/Editor/LinkDownloaderEditor.asmdef.meta new file mode 100644 index 0000000..4c803bd --- /dev/null +++ b/LinkDownloader/Editor/LinkDownloaderEditor.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 7eb3c7b8f35f15040802ea8b346b1691 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/LinkDownloader/Editor/LinkDownloaderPlugin.cs b/LinkDownloader/Editor/LinkDownloaderPlugin.cs new file mode 100644 index 0000000..bd3a6f8 --- /dev/null +++ b/LinkDownloader/Editor/LinkDownloaderPlugin.cs @@ -0,0 +1,41 @@ +using System.IO; +using System.Net.Http; +using gay.lilyy.LinkDownloader; +using nadena.dev.ndmf; +using UnityEditor; +using UnityEngine; + +[assembly: ExportsPlugin(typeof(LinkDownloaderPlugin))] + +namespace gay.lilyy.LinkDownloader +{ + public class LinkDownloaderPlugin : Plugin + { + public override string DisplayName => "LinkDownloader"; + public override string QualifiedName => "gay.lilyy.LinkDownloader"; + + protected override void Configure() + { + InPhase(BuildPhase.Transforming).Run("LinkDownloader", async ctx => + { + var links = ctx.AvatarRootObject.GetComponentsInChildren(); + if (links.Length == 0) return; + using var http = new HttpClient(); + foreach (var link in links) { + try + { + Debug.Log($"Downloading {link.link} to {link.path}"); + var data = await http.GetByteArrayAsync(link.link); + File.WriteAllBytes(link.path, data); + Debug.Log($"Link saved to: {link.path}"); + } + catch (System.Exception ex) + { + Debug.LogError($"Failed to download link: {ex.Message}"); + } + } + AssetDatabase.Refresh(); + }); + } + } +} diff --git a/LinkDownloader/Editor/LinkDownloaderPlugin.cs.meta b/LinkDownloader/Editor/LinkDownloaderPlugin.cs.meta new file mode 100644 index 0000000..3713439 --- /dev/null +++ b/LinkDownloader/Editor/LinkDownloaderPlugin.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e589545f2ee61974e9d5ee2ac410072a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/LinkDownloader/Runtime.meta b/LinkDownloader/Runtime.meta new file mode 100644 index 0000000..1899cb1 --- /dev/null +++ b/LinkDownloader/Runtime.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: aa4b90537194d334a87ce37af3b678d0 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/LinkDownloader/Runtime/LinkDownloaderConfig.cs b/LinkDownloader/Runtime/LinkDownloaderConfig.cs new file mode 100644 index 0000000..20a61ad --- /dev/null +++ b/LinkDownloader/Runtime/LinkDownloaderConfig.cs @@ -0,0 +1,12 @@ + +using UnityEngine; + +namespace gay.lilyy.LinkDownloader +{ + [AddComponentMenu("LillithRosePup/Link Downloader")] + public class LinkDownloaderConfig : MonoBehaviour, VRC.SDKBase.IEditorOnly + { + public string link; + public string path; + } +} \ No newline at end of file diff --git a/LinkDownloader/Runtime/LinkDownloaderConfig.cs.meta b/LinkDownloader/Runtime/LinkDownloaderConfig.cs.meta new file mode 100644 index 0000000..c9421c4 --- /dev/null +++ b/LinkDownloader/Runtime/LinkDownloaderConfig.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c85a026f51d936847b96ac9fd236ed0c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/LinkDownloader/Runtime/LinkDownloaderRuntime.asmdef b/LinkDownloader/Runtime/LinkDownloaderRuntime.asmdef new file mode 100644 index 0000000..e753804 --- /dev/null +++ b/LinkDownloader/Runtime/LinkDownloaderRuntime.asmdef @@ -0,0 +1,14 @@ +{ + "name": "LinkDownloaderRuntime", + "rootNamespace": "", + "references": [], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/LinkDownloader/Runtime/LinkDownloaderRuntime.asmdef.meta b/LinkDownloader/Runtime/LinkDownloaderRuntime.asmdef.meta new file mode 100644 index 0000000..22330eb --- /dev/null +++ b/LinkDownloader/Runtime/LinkDownloaderRuntime.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: f7a3c1e913875bf4896e48f991fdd5a6 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: