Exemple #1
0
        private static void WaitForEditorApplicationUpdate()
        {
            if (listRequest == null)
            {
                listRequest = UnityEditor.PackageManager.Client.List();
            }

            if (listRequest.IsCompleted == false)
            {
                return;
            }
            else if (listRequest.Status == StatusCode.Failure)
            {
                // UB can't occur in this case.
                // ReSharper disable once DelegateSubtraction
                EditorApplication.update -= WaitForEditorApplicationUpdate;
                return;
            }

            PackageCollection listRequestResult = listRequest.Result;

            string[] packageData = openVrPackageName.Split('@');

            if (listRequestResult.Any(packageInfo => packageInfo.name == packageData[0] && packageInfo.version == packageData[1]) == false)
            {
                UnityEditor.PackageManager.Client.Add(openVrPackageName);
                logger.InfoFormat("The 'OpenVR' package was not a dependency of this Unity project. The package 'OpenVR ({0})' has been automatically added.", openVrPackageName);
            }

            // UB can't occur in this case.
            // ReSharper disable once DelegateSubtraction
            EditorApplication.update -= WaitForEditorApplicationUpdate;
        }
Exemple #2
0
        private static void ProcessSuccessInListCollection(PackageCollection listRequestResult)
        {
            const string cecil = "nuget.mono-cecil";

            if (listRequestResult.Any(info => info.name == cecil))
            {
                ImportPackage();
                return;
            }

            AddRequest = Client.Add(cecil);
            EditorApplication.update += AddRequestDone;
        }