link downloader
This commit is contained in:
parent
a8d5ba8ba1
commit
449ee2f194
11 changed files with 146 additions and 0 deletions
8
LinkDownloader.meta
Normal file
8
LinkDownloader.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6faa76d34adb0ca48bcf418bccf1149b
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
LinkDownloader/Editor.meta
Normal file
8
LinkDownloader/Editor.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6c117da7fe8d0604ca33a833223beebe
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
19
LinkDownloader/Editor/LinkDownloaderEditor.asmdef
Normal file
19
LinkDownloader/Editor/LinkDownloaderEditor.asmdef
Normal 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
|
||||||
|
}
|
||||||
7
LinkDownloader/Editor/LinkDownloaderEditor.asmdef.meta
Normal file
7
LinkDownloader/Editor/LinkDownloaderEditor.asmdef.meta
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7eb3c7b8f35f15040802ea8b346b1691
|
||||||
|
AssemblyDefinitionImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
41
LinkDownloader/Editor/LinkDownloaderPlugin.cs
Normal file
41
LinkDownloader/Editor/LinkDownloaderPlugin.cs
Normal 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();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
LinkDownloader/Editor/LinkDownloaderPlugin.cs.meta
Normal file
11
LinkDownloader/Editor/LinkDownloaderPlugin.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e589545f2ee61974e9d5ee2ac410072a
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
LinkDownloader/Runtime.meta
Normal file
8
LinkDownloader/Runtime.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: aa4b90537194d334a87ce37af3b678d0
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
12
LinkDownloader/Runtime/LinkDownloaderConfig.cs
Normal file
12
LinkDownloader/Runtime/LinkDownloaderConfig.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
11
LinkDownloader/Runtime/LinkDownloaderConfig.cs.meta
Normal file
11
LinkDownloader/Runtime/LinkDownloaderConfig.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c85a026f51d936847b96ac9fd236ed0c
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
14
LinkDownloader/Runtime/LinkDownloaderRuntime.asmdef
Normal file
14
LinkDownloader/Runtime/LinkDownloaderRuntime.asmdef
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"name": "LinkDownloaderRuntime",
|
||||||
|
"rootNamespace": "",
|
||||||
|
"references": [],
|
||||||
|
"includePlatforms": [],
|
||||||
|
"excludePlatforms": [],
|
||||||
|
"allowUnsafeCode": false,
|
||||||
|
"overrideReferences": false,
|
||||||
|
"precompiledReferences": [],
|
||||||
|
"autoReferenced": true,
|
||||||
|
"defineConstraints": [],
|
||||||
|
"versionDefines": [],
|
||||||
|
"noEngineReferences": false
|
||||||
|
}
|
||||||
7
LinkDownloader/Runtime/LinkDownloaderRuntime.asmdef.meta
Normal file
7
LinkDownloader/Runtime/LinkDownloaderRuntime.asmdef.meta
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f7a3c1e913875bf4896e48f991fdd5a6
|
||||||
|
AssemblyDefinitionImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Loading…
Add table
Add a link
Reference in a new issue