Add VRChat and GitHub packages to Unity project
This commit is contained in:
1 parent
0334a52b21
commit
85538aaccc
3297 files changed
+847877
No files matched your search
@@ -0,0 +1,71 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEditor.PackageManager;
|
||||
using UnityEditor.PackageManager.Requests;
|
||||
using UnityEngine;
|
||||
|
||||
namespace VRC.Udon.Editor {
|
||||
[InitializeOnLoad]
|
||||
public class UPMImporter
|
||||
{
|
||||
// Add packages here to auto-import
|
||||
public static string[] requiredPackages =
|
||||
{
|
||||
"com.unity.cinemachine@2.6.3",
|
||||
"com.unity.postprocessing@2.3.0",
|
||||
"com.unity.textmeshpro@1.4.1",
|
||||
};
|
||||
|
||||
private static ListRequest list;
|
||||
|
||||
static UPMImporter()
|
||||
{
|
||||
list = Client.List();
|
||||
EditorApplication.update += Update;
|
||||
}
|
||||
|
||||
public static void Update()
|
||||
{
|
||||
// Exit early if we're still gathering the list
|
||||
if (!list.IsCompleted) return;
|
||||
|
||||
// Unsubscribe from Update once the list is ready
|
||||
EditorApplication.update -= Update;
|
||||
|
||||
var localPackages = list.Result;
|
||||
bool importedNewPackage = false;
|
||||
foreach (string packageName in requiredPackages)
|
||||
{
|
||||
var packageNameNoVersion = packageName.Substring(0, packageName.IndexOf('@'));
|
||||
if(!localPackages.Any(p => p.name == packageNameNoVersion))
|
||||
{
|
||||
Install(packageName);
|
||||
importedNewPackage = true;
|
||||
}
|
||||
}
|
||||
|
||||
// if Unity tried to import SDK3 before required packages, it will have old errors showing.
|
||||
if(importedNewPackage) ClearLog();
|
||||
}
|
||||
|
||||
public static bool Install(string id)
|
||||
{
|
||||
var request = Client.Add(id);
|
||||
while (!request.IsCompleted) {};
|
||||
if(request.Error != null)Debug.LogError(request.Error.message);
|
||||
return request.Error == null;
|
||||
}
|
||||
|
||||
public static void ClearLog()
|
||||
{
|
||||
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetAssembly(typeof(SceneView));
|
||||
|
||||
System.Type type = assembly.GetType("UnityEditor.LogEntries");
|
||||
System.Reflection.MethodInfo method = type.GetMethod("Clear");
|
||||
method.Invoke(new object(), null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1056c67d11ce3ce41b80a979e05732c4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "VRC.Udon.Editor.UPMImporter",
|
||||
"references": [],
|
||||
"optionalUnityReferences": [],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": []
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4704b64fff8057d49a97d061be599eea
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user