link downloader

This commit is contained in:
Lillith Rose 2025-10-05 21:17:34 -04:00
parent a8d5ba8ba1
commit 449ee2f194
11 changed files with 146 additions and 0 deletions

8
LinkDownloader.meta Normal file
View file

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

View file

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

View file

@ -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
}

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 7eb3c7b8f35f15040802ea8b346b1691
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -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<LinkDownloaderPlugin>
{
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<LinkDownloaderConfig>();
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();
});
}
}
}

View file

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

View file

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

View file

@ -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;
}
}

View file

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

View file

@ -0,0 +1,14 @@
{
"name": "LinkDownloaderRuntime",
"rootNamespace": "",
"references": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f7a3c1e913875bf4896e48f991fdd5a6
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: