Ejemplo n.º 1
0
//----------------------------------------------------------------------------------------------------------------------
        void CopyDCCPluginsFromPackage(string dccPluginVersion, Action <string> onSuccess, Action <string> onFail)
        {
            PackageRequestJobManager.CreateListRequest(/*offlineMode=*/ true, /*includeIndirectIndependencies=*/ true,
                                                       /*onSuccess=*/ (listReq) => {
                PackageInfo packageInfo = listReq.FindPackage(MESHSYNC_DCC_PLUGIN_PACKAGE);
                if (null != packageInfo && packageInfo.version == dccPluginVersion)
                {
                    //Package is already installed.
                    CopyDCCPluginsFromPackage(dccPluginVersion);
                    onSuccess(packageInfo.version);
                    return;
                }

                string packageNameAndVer = $"{MESHSYNC_DCC_PLUGIN_PACKAGE}@{dccPluginVersion}";
                PackageRequestJobManager.CreateAddRequest(packageNameAndVer,
                                                          /*onSuccess=*/ (addReq) => {
                    //Package was successfully added
                    CopyDCCPluginsFromPackage(dccPluginVersion);
                    onSuccess(dccPluginVersion);
                },
                                                          /*onFail=*/ (req) => {
                    PackageInfo meshSyncInfo = listReq.FindPackage(MeshSyncConstants.PACKAGE_NAME);
                    onFail?.Invoke(meshSyncInfo.version);
                });
            },
                                                       /*OnFail=*/ null
                                                       );
        }
        public IEnumerator CheckPackageIsInstalled()
        {
            bool done         = false;
            bool packageFound = false;

            PackageRequestJobManager.CreateListRequest(/*offlineMode*/ true, /*includeIndirectIndependencies= */ true,
                                                       /*onSuccess=*/ (packageCollectionReq) => {
                if (null == packageCollectionReq)
                {
                    done = true;
                    return;
                }
                foreach (PackageInfo packageInfo in packageCollectionReq.Result)
                {
                    if (packageInfo.name != FilmInternalUtilitiesEditorConstants.PACKAGE_NAME)
                    {
                        continue;
                    }

                    packageFound = true;
                    done         = true;
                    return;
                }
                done = true;
            },
                                                       /*onFail=*/ (packageCollectionReq) => {
                done = true;
            }
                                                       );

            while (!done)
            {
                yield return(null);
            }

            Assert.IsTrue(packageFound);
        }