赞
踩
看油管的。写链接敏感了。
Editor + 程序集定义(资源,创建。不加不会运行) + json。以下三个文件/夹按下面步骤得到
using System.Collections; using System.Collections.Generic; using UnityEngine; using Random = UnityEngine.Random; using static System.IO.Directory; using static System.IO.Path; using static UnityEngine.Application; using static UnityEditor.AssetDatabase; using UnityEditor; namespace NewBehaviourScript00 { public static class ToolsMenu { [MenuItem("My/Setup/Create Default Folders")] public static void CreateDefaultFolders() { Dir( "_Project","Scripts","Art","Scene"); Refresh(); } public static void Dir(string root, params string[] dir) { var fullPath = Combine( dataPath, root); foreach (var newDirectory in dir) { CreateDirectory( Combine(fullPath, newDirectory)); } } } }
{
"name": "com.wuweisheng.tools",
"version": "0.0.1-preview.1",
"displayName": "创建目录"
}
按视频前后差异
类似目录D:\Data\Projects\Unity\U_Test\Packages\manifest.json(不允许//注释符,下面只是看Up删除了哪些)
{ "dependencies": { "com.unity.collab-proxy": "1.13.5", "com.unity.ide.rider": "3.0.7", //"com.unity.ide.visualstudio": "2.0.11",//负责比如unity双击脚本后打开visual studio //"com.unity.ide.vscode": "1.2.4", //"com.unity.test-framework": "1.1.29", "com.unity.textmeshpro": "3.0.6", "com.unity.timeline": "1.6.2", "com.unity.ugui": "1.0.0", //"com.unity.visualscripting": "1.7.2", "com.unity.modules.ai": "1.0.0", "com.unity.modules.androidjni": "1.0.0", "com.unity.modules.animation": "1.0.0", //"com.unity.modules.assetbundle": "1.0.0", "com.unity.modules.audio": "1.0.0", //"com.unity.modules.cloth": "1.0.0", //"com.unity.modules.director": "1.0.0", "com.unity.modules.imageconversion": "1.0.0", "com.unity.modules.imgui": "1.0.0", "com.unity.modules.jsonserialize": "1.0.0", "com.unity.modules.particlesystem": "1.0.0", "com.unity.modules.physics": "1.0.0", //"com.unity.modules.physics2d": "1.0.0", //"com.unity.modules.screencapture": "1.0.0", //"com.unity.modules.terrain": "1.0.0", //"com.unity.modules.terrainphysics": "1.0.0", //"com.unity.modules.tilemap": "1.0.0", "com.unity.modules.ui": "1.0.0", "com.unity.modules.uielements": "1.0.0", "com.unity.modules.umbra": "1.0.0", //"com.unity.modules.unityanalytics": "1.0.0", "com.unity.modules.unitywebrequest": "1.0.0", "com.unity.modules.unitywebrequestassetbundle": "1.0.0", //"com.unity.modules.unitywebrequestaudio": "1.0.0", //"com.unity.modules.unitywebrequesttexture": "1.0.0", "com.unity.modules.unitywebrequestwww": "1.0.0" //"com.unity.modules.vehicles": "1.0.0", //"com.unity.modules.video": "1.0.0", //"com.unity.modules.vr": "1.0.0", //"com.unity.modules.wind": "1.0.0", //"com.unity.modules.xr": "1.0.0" } }
{ "dependencies": { "com.unity.collab-proxy": "1.13.5", "com.unity.ide.rider": "3.0.7", "com.unity.textmeshpro": "3.0.6", "com.unity.timeline": "1.6.2", "com.unity.ugui": "1.0.0", "com.unity.modules.ai": "1.0.0", "com.unity.modules.androidjni": "1.0.0", "com.unity.modules.animation": "1.0.0", "com.unity.modules.audio": "1.0.0", "com.unity.modules.imageconversion": "1.0.0", "com.unity.modules.imgui": "1.0.0", "com.unity.modules.jsonserialize": "1.0.0", "com.unity.modules.particlesystem": "1.0.0", "com.unity.modules.physics": "1.0.0", "com.unity.modules.ui": "1.0.0", "com.unity.modules.uielements": "1.0.0", "com.unity.modules.umbra": "1.0.0", "com.unity.modules.unitywebrequest": "1.0.0", "com.unity.modules.unitywebrequestassetbundle": "1.0.0", "com.unity.modules.unitywebrequestwww": "1.0.0" } }
using UnityEngine; using Random = UnityEngine.Random; using static System.IO.Directory; using static System.IO.Path; using static UnityEngine.Application; using static UnityEditor.AssetDatabase; using UnityEditor; using System.Threading.Tasks; using System.Net.Http; using System.IO; using System; namespace NewBehaviourScript00 { public static class ToolsMenu { public const string topItem = "MyTools"; #region 导包 /// <summary>https://gist.github.com/给你的ID</summary> const string gistID = "2dba9dc3384c1a2e1b6d3299052f317a"; [MenuItem(topItem + "/Setup/Load New Manifest")] static async void LoadNewManifest() => await Packages.ReplacePaackagesFromGist(id: gistID ); [MenuItem(topItem + "/Setup/输入系统")] static void AddNewInputSystem() => Packages.InstallUnitPackage("inputsystem"); [MenuItem(topItem + "/Setup/后期处理")] static void AddPostPocessing() => Packages.InstallUnitPackage("postprocessing"); [MenuItem(topItem + "/Setup/摄像机")] static void AddCinemachine() => Packages.InstallUnitPackage("cinemachine"); #endregion } public static class Packages { /// <summary>你的github账户名字</summary> const string githubName = "WarbleWavelet"; /// <summary>拿到manifest,进行包的下载</summary> public static async Task ReplacePaackagesFromGist( string id, string user= githubName) { var url = GetGistUrl(id, user); var contents = await GetContents(url); ReplacePackageFile(contents); } /// <summary>https://gist.github.com/ 填写你精简后的manifest得到的来宾ID</summary> private static string GetGistUrl(string id, string user = githubName) { return $"https://gist.githubusercontent.com/{user}/{id}/raw"; } /// <summary>下载</summary> public static async Task<string> GetContents(string url) { var client = new HttpClient(); var response = await client.GetAsync(url); var content = await response.Content.ReadAsStringAsync(); return content; } /// <summary>覆盖本地manifest.json</summary> public static void ReplacePackageFile(string contents) { var existing = Path.Combine(Application.dataPath, "../Packages/manifest.json"); File.WriteAllText(existing, contents); UnityEditor.PackageManager.Client.Resolve(); } /// <summary>相当于在包管理器安装包</summary> internal static void InstallUnitPackage(string packageName) { UnityEditor.PackageManager.Client.Add($"com.unity.{packageName}") ; } } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。