diff --git a/Unity/Assets/Ubiq/Editor/Packages/AddPackageWebRTC.cs b/Unity/Assets/Ubiq/Editor/Packages/AddPackageWebRTC.cs index 295a3553c..10fcc0633 100644 --- a/Unity/Assets/Ubiq/Editor/Packages/AddPackageWebRTC.cs +++ b/Unity/Assets/Ubiq/Editor/Packages/AddPackageWebRTC.cs @@ -25,9 +25,13 @@ static void Update() " behaviour, add the string" + " UBIQ_DISABLE_WEBRTCCOMPATIBILITYCHECK to your scripting define" + " symbols."); - PackageManagerHelper.RemoveProvider("com.unity.webrtc"); + PackageManagerHelper.RemovePackage("com.unity.webrtc"); #endif - PackageManagerHelper.AddPackage("https://github.com/UCL-VR/unity-webrtc-ubiq-fork.git"); + // Remove previous versions + PackageManagerHelper.RemovePackage("com.unity.webrtc-no-vulkan-hook"); + PackageManagerHelper.RemovePackage("com.unity.webrtc-ubiq-fork"); + + PackageManagerHelper.AddPackage("https://github.com/UCL-VR/unity-webrtc-ubiq-fork.git#v3.0.1-pre.7"); EditorApplication.update -= Update; } } diff --git a/Unity/Assets/Ubiq/Editor/Packages/PackageManagerHelper.cs b/Unity/Assets/Ubiq/Editor/Packages/PackageManagerHelper.cs index a82af48d5..2d270fb40 100644 --- a/Unity/Assets/Ubiq/Editor/Packages/PackageManagerHelper.cs +++ b/Unity/Assets/Ubiq/Editor/Packages/PackageManagerHelper.cs @@ -106,17 +106,9 @@ private static IEnumerator Process() private static IEnumerator ProcessPackages() { - var upmRequest = null as AddAndRemoveRequest; - if (packageRequests.Count > 0) - { - GetUnique(packageRequests, out var adds, out var removes); - LogPackageModificationMessage(adds,removes); - -#if !UBIQ_DISABLE_PACKAGEIMPORT - upmRequest = Client.AddAndRemove(adds,removes); -#else +#if UBIQ_DISABLE_PACKAGEIMPORT #if !UBIQ_SILENCEWARNING_DISABLEPACKAGEIMPORT - Debug.LogWarning("Ubiq will not modify packages as the" + + Debug.LogWarning("Ubiq will not modify packages as the" + " scripting define symbol UBIQ_DISABLE_PACKAGEIMPORT is" + " present. Please ensure you manage the required packages" + " manually, or Ubiq may not function as intended. To" + @@ -124,10 +116,35 @@ private static IEnumerator ProcessPackages() " UBIQ_SILENCEWARNING_DISABLEPACKAGEIMPORT to your scripting" " define symbols."); #endif + packageRequests.Clear(); + yield break; #endif - packageRequests.Clear(); + + if (packageRequests.Count == 0) + { + yield break; + } + + GetUnique(packageRequests, out var adds, out var removes); + packageRequests.Clear(); + LogPackageModificationMessage(adds,removes); + + // First check if the packages for removal are present + var listRequest = Client.List( + offlineMode:true,includeIndirectDependencies:false); + while (listRequest != null) + { + if (listRequest.IsCompleted) + { + Filter(ref removes, listRequest.Result); + listRequest = null; + } + + yield return null; } + // Now do the actual add/remove + var upmRequest = Client.AddAndRemove(adds,removes); while (upmRequest != null) { if (upmRequest.Status == StatusCode.Failure) @@ -138,10 +155,8 @@ private static IEnumerator ProcessPackages() Debug.LogError($"Ubiq was unable to modify project requirements. Error: {error}"); upmRequest = null; } - - if (upmRequest.Status == StatusCode.Success) + else if (upmRequest.Status == StatusCode.Success) { - var collection = (PackageCollection)upmRequest.Result; Debug.Log("Ubiq successfully modified project requirements."); upmRequest = null; assetsDirty = true; @@ -149,6 +164,8 @@ private static IEnumerator ProcessPackages() yield return null; } + + yield return null; } private static IEnumerator ProcessSamples() @@ -247,6 +264,24 @@ private static List GetRequiredSamples(List requests) } return samples; } + + private static void Filter(ref string[] names, PackageCollection collection) + { + var result = new List(); + foreach (var requestedPackage in names) + { + foreach (var existingPackage in collection) + { + if (existingPackage.name == requestedPackage) + { + result.Add(requestedPackage); + break; + } + } + } + + names = result.ToArray(); + } private static void GetUnique(List requests, out string[] adds, out string[] removes) diff --git a/Unity/Assets/Ubiq/Runtime/Voip/Implementations/Unity/Ubiq.Voip.Implementations.Unity.asmdef b/Unity/Assets/Ubiq/Runtime/Voip/Implementations/Unity/Ubiq.Voip.Implementations.Unity.asmdef index e7048add3..faa37aeb1 100644 --- a/Unity/Assets/Ubiq/Runtime/Voip/Implementations/Unity/Ubiq.Voip.Implementations.Unity.asmdef +++ b/Unity/Assets/Ubiq/Runtime/Voip/Implementations/Unity/Ubiq.Voip.Implementations.Unity.asmdef @@ -27,7 +27,7 @@ }, { "name": "com.unity.webrtc-ubiq-fork", - "expression": "0.0.0", + "expression": "3.0.1-pre.7", "define": "UNITY_WEBRTC_UBIQ_FORK" } ],