private void ResolveDependencies()
        {
            var container = ServicesContainer.instance;

            m_Selection     = container.Resolve <SelectionProxy>();
            m_AssetDatabase = container.Resolve <AssetDatabaseProxy>();
        }
示例#2
0
 internal Sample(IOProxy ioProxy, AssetDatabaseProxy assetDatabase, string displayName, string description, string resolvedPath, string importPath, bool interactiveImport)
 {
     m_IOProxy              = ioProxy;
     m_AssetDatabase        = assetDatabase;
     this.displayName       = displayName;
     this.description       = description;
     this.resolvedPath      = resolvedPath;
     this.importPath        = importPath;
     this.interactiveImport = interactiveImport;
 }
        public void ResolveDependencies(UnityConnectProxy unityConnect,
                                        AssetDatabaseProxy assetDatabase,
                                        AssetStoreUtils assetStoreUtils,
                                        AssetStoreClient assetStoreClient,
                                        AssetStoreDownloadManager assetStoreDownloadManager,
                                        UpmClient upmClient,
                                        IOProxy ioProxy)
        {
            m_UnityConnect              = unityConnect;
            m_AssetDatabase             = assetDatabase;
            m_AssetStoreClient          = assetStoreClient;
            m_AssetStoreDownloadManager = assetStoreDownloadManager;
            m_UpmClient = upmClient;
            m_IOProxy   = ioProxy;

            foreach (var package in m_SerializedAssetStorePackages)
            {
                package.ResolveDependencies(assetStoreUtils, ioProxy);
            }
        }
示例#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;
        }
        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>());
            }
        }