Пример #1
0
        internal static IEnumerable <Sample> FindByPackage(PackageInfo package, UpmCache upmCache, IOProxy ioProxy, AssetDatabaseProxy assetDatabaseProxy)
        {
            if (string.IsNullOrEmpty(package?.upmReserved) && string.IsNullOrEmpty(package.resolvedPath))
            {
                return(Enumerable.Empty <Sample>());
            }

            try
            {
                IEnumerable <IDictionary <string, object> > samples = null;
                var upmReserved = upmCache.ParseUpmReserved(package);
                if (upmReserved != null)
                {
                    samples = upmReserved.GetList <IDictionary <string, object> >("samples");
                }

                if (samples == null)
                {
                    var jsonPath = ioProxy.PathsCombine(package.resolvedPath, "package.json");
                    if (ioProxy.FileExists(jsonPath))
                    {
                        var packageJson = Json.Deserialize(ioProxy.FileReadAllText(jsonPath)) as Dictionary <string, object>;
                        samples = packageJson.GetList <IDictionary <string, object> >("samples");
                    }
                }

                return(samples?.Select(sample =>
                {
                    var displayName = sample.GetString("displayName");
                    var path = sample.GetString("path");
                    var description = sample.GetString("description");
                    var interactiveImport = sample.Get("interactiveImport", false);

                    var resolvedSamplePath = ioProxy.PathsCombine(package.resolvedPath, path);
                    var importPath = ioProxy.PathsCombine(
                        Application.dataPath,
                        "Samples",
                        IOUtils.SanitizeFileName(package.displayName),
                        package.version,
                        string.IsNullOrEmpty(displayName) ? string.Empty : IOUtils.SanitizeFileName(displayName)
                        );
                    return new Sample(ioProxy, assetDatabaseProxy, displayName, description, resolvedSamplePath, importPath, interactiveImport);
                }).ToArray() ?? Enumerable.Empty <Sample>());
            }
            catch (IOException e)
            {
                Debug.Log($"[Package Manager Window] Cannot find samples for package {package.displayName}: {e}");
                return(Enumerable.Empty <Sample>());
            }
            catch (InvalidCastException e)
            {
                Debug.Log($"[Package Manager Window] Invalid sample data for package {package.displayName}: {e}");
                return(Enumerable.Empty <Sample>());
            }
            catch (Exception)
            {
                return(Enumerable.Empty <Sample>());
            }
        }
Пример #2
0
 public void ResolveDependencies(PackageManagerPrefs packageManagerPrefs,
                                 UpmCache upmCache,
                                 IOProxy IOProxy)
 {
     m_PackageManagerPrefs = packageManagerPrefs;
     m_UpmCache            = upmCache;
     m_IOProxy             = IOProxy;
 }
Пример #3
0
 public void ResolveDependencies(PackageManagerPrefs packageManagerPrefs,
                                 UpmCache upmCache,
                                 IOProxy IOProxy,
                                 PackageManagerProjectSettingsProxy settingsProxy)
 {
     m_PackageManagerPrefs = packageManagerPrefs;
     m_UpmCache            = upmCache;
     m_IOProxy             = IOProxy;
     m_SettingsProxy       = settingsProxy;
 }
Пример #4
0
        public ServicesContainer()
        {
            // In the constructor we only need to worry about creating a brand new instance.
            // In the case of assembly reload, a deserialize step will automatically happen after the constructor
            // to restore all the serializable states/services and we don't need to worry about that
            m_HttpClientFactory  = new HttpClientFactory();
            m_UnityOAuthProxy    = new UnityOAuthProxy();
            m_SelectionProxy     = new SelectionProxy();
            m_AssetDatabaseProxy = new AssetDatabaseProxy();
            m_UnityConnectProxy  = new UnityConnectProxy();
            m_ApplicationProxy   = new ApplicationProxy();
            m_IOProxy            = new IOProxy();
            m_SettingsProxy      = new PackageManagerProjectSettingsProxy();

            m_ResourceLoader = new ResourceLoader();

            m_AssetStoreCache           = new AssetStoreCache();
            m_AssetStoreClient          = new AssetStoreClient();
            m_AssetStoreOAuth           = new AssetStoreOAuth();
            m_AssetStoreUtils           = new AssetStoreUtils();
            m_AssetStoreRestAPI         = new AssetStoreRestAPI();
            m_AssetStoreDownloadManager = new AssetStoreDownloadManager();

            m_UpmCache  = new UpmCache();
            m_UpmClient = new UpmClient();

            m_PackageFiltering    = new PackageFiltering();
            m_PackageManagerPrefs = new PackageManagerPrefs();

            m_PackageDatabase = new PackageDatabase();
            m_PageManager     = new PageManager();

            // Since dictionaries doesn't survive through serialization, we always re-create the default registration
            m_RegisteredObjects = new Dictionary <Type, object>();
            RegisterDefaultServices();

            m_DependenciesResolved = false;
        }