using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEditor; using UnityEditor.PackageManager; using System.IO; using Newtonsoft.Json; using System; using HIKKY.VketCloudSDK.GUITools.Utility; [InitializeOnLoad] public class ExternalPackageImporter { static ExternalPackageImporter() { var Request = Client.Add("https://github.com/Cysharp/UniTask.git?path=src/UniTask/Assets/Plugins/UniTask"); while (!Request.IsCompleted) { } CreateSymbol.AddSymbol("UniTask"); var Request2 = Client.Add("com.unity.nuget.newtonsoft-json"); while (!Request2.IsCompleted) { } CreateSymbol.AddSymbol("NewtonsoftJson"); } public static void AddScopedRegistry(ScopedRegistry pScopeRegistry) { var manifestPath = Path.Combine(Application.dataPath, "..", "Packages/manifest.json"); var manifestJson = File.ReadAllText(manifestPath); var manifest = JsonConvert.DeserializeObject(manifestJson); if (manifest.scopedRegistries.Find(n => n.name == pScopeRegistry.name) == null) { Debug.Log($"{pScopeRegistry.name}_Importing"); manifest.scopedRegistries.Add(pScopeRegistry); File.WriteAllText(manifestPath, JsonConvert.SerializeObject(manifest, Formatting.Indented)); } else { return; } foreach(var scope in pScopeRegistry.scopes) Client.Add(scope); } public class ScopedRegistry { public string name; public string url; public string[] scopes; } public class ManifestJson { public Dictionary dependencies = new Dictionary(); public List scopedRegistries = new List(); } }