浏览代码
Install python for unity dependency only when editor is on Windows or Macos
/pyrception-integration
Install python for unity dependency only when editor is on Windows or Macos
/pyrception-integration
leopoldo-zugasti
3 年前
当前提交
81297e14
共有 5 个文件被更改,包括 91 次插入 和 10 次删除
-
2com.unity.perception/Editor/Visualizer/PipAPI.cs
-
18com.unity.perception/Editor/Visualizer/VisualizerInstaller.cs
-
5com.unity.perception/package.json
-
65com.unity.perception/Editor/Visualizer/PythonForUnityInstaller.cs
-
11com.unity.perception/Editor/Visualizer/PythonForUnityInstaller.cs.meta
|
|||
#if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || true
|
|||
using System; |
|||
using UnityEditor; |
|||
using UnityEditor.PackageManager.Requests; |
|||
using UnityEditor.PackageManager; |
|||
using UnityEngine; |
|||
using System.Threading; |
|||
|
|||
namespace UnityEditor.Perception.Visualizer |
|||
{ |
|||
#if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX
|
|||
[InitializeOnLoad] |
|||
#endif
|
|||
internal static class PythonForUnityInstaller |
|||
{ |
|||
#if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX
|
|||
static PythonForUnityInstaller() |
|||
{ |
|||
Add(); |
|||
} |
|||
#endif
|
|||
|
|||
internal static void Add() |
|||
{ |
|||
if (!checkIfPackageInstalled()) |
|||
{ |
|||
AddRequest request = Client.Add("com.unity.scripting.python@4.0.0-exp.5"); |
|||
|
|||
EditorUtility.DisplayProgressBar("Setting up the Visualizer", "Installing the Visualizer...", 0.2f); |
|||
|
|||
while (!request.IsCompleted) |
|||
{ |
|||
Thread.Sleep(100); |
|||
} |
|||
if (request.Status == StatusCode.Success) |
|||
Debug.Log("Installed: " + request.Result.packageId); |
|||
else if (request.Status >= StatusCode.Failure) |
|||
Debug.Log(request.Error.message); |
|||
} |
|||
} |
|||
|
|||
static bool checkIfPackageInstalled() |
|||
{ |
|||
ListRequest request = Client.List(); |
|||
while (!request.IsCompleted) |
|||
{ |
|||
Thread.Sleep(100); |
|||
} |
|||
if (request.Status == StatusCode.Success) |
|||
{ |
|||
foreach (var package in request.Result) |
|||
{ |
|||
if (package.packageId.Contains("com.unity.scripting.python")) |
|||
{ |
|||
return true; |
|||
} |
|||
} |
|||
} |
|||
else if (request.Status >= StatusCode.Failure) |
|||
Debug.LogError(request.Error.message); |
|||
return false; |
|||
} |
|||
} |
|||
} |
|||
#endif
|
|
|||
fileFormatVersion: 2 |
|||
guid: a2b3dd102c3620042b77a9d621a05630 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue