public PrefabImportCache(Lifetime lifetime, ISolution solution, ISettingsStore store, MetaFileGuidCache metaFileGuidCache, UnityExternalFilesModuleFactory unityExternalFilesModuleFactory, IShellLocks shellLocks)
        {
            myMetaFileGuidCache = metaFileGuidCache;
            myShellLocks        = shellLocks;
            metaFileGuidCache.GuidChanged.Advise(lifetime, e =>
            {
                myShellLocks.AssertWriteAccessAllowed();
                var set = new HashSet <Guid>();
                if (e.oldGuid != null)
                {
                    InvalidateImportCache(e.oldGuid.Value, set);
                }

                if (e.newGuid != null)
                {
                    InvalidateImportCache(e.newGuid.Value, set);
                }
            });

            myUnityExternalFilesPsiModule = unityExternalFilesModuleFactory.PsiModule;

            var boundSettingsStoreLive = store.BindToContextLive(lifetime, ContextRange.Smart(solution.ToDataContext()));

            myCacheEnabled = boundSettingsStoreLive.GetValueProperty(lifetime, (UnitySettings key) => key.IsPrefabCacheEnabled);
        }
示例#2
0
 public AssetDocumentHierarchyElementContainer(IPersistentIndexManager manager, PrefabImportCache prefabImportCache, IShellLocks shellLocks,
                                               UnityExternalFilesModuleFactory psiModuleProvider, MetaFileGuidCache metaFileGuidCache, IEnumerable <IAssetInspectorValueDeserializer> assetInspectorValueDeserializers)
 {
     myManager           = manager;
     myPrefabImportCache = prefabImportCache;
     myShellLocks        = shellLocks;
     myPsiModule         = psiModuleProvider.PsiModule;
     myMetaFileGuidCache = metaFileGuidCache;
     myAssetInspectorValueDeserializers = assetInspectorValueDeserializers;
 }
示例#3
0
        private IEnumerable <(IPsiSourceFile file, string unityPath)> GetCorrespondingSourceFiles(string scene, UnityExternalFilesPsiModule psiModule)
        {
            var files = psiModule.SourceFiles;

            if (IsScenePath(scene))
            {
                var sceneName = scene.Split('/').Last();
                bool IsCorrespondingSourceFile(IPsiSourceFile psiSourceFile)
                {
                    if (!psiSourceFile.GetExtensionWithDot().Equals(UnityYamlFileExtensions.SceneFileExtensionWithDot))
                    {
                        return(false);
                    }
                    var psiPath = psiSourceFile.GetLocation();

                    if (!psiPath.NameWithoutExtension.Equals(sceneName))
                    {
                        return(false);
                    }

                    return(GetUnityPathFor(psiSourceFile).Equals(scene));
                }

                var file = files.FirstOrDefault(IsCorrespondingSourceFile);
                if (file == null)
                {
                    return(EmptyList <(IPsiSourceFile, string)> .Instance);
                }
                return(new[] { (file, GetUnityPathFor(file)) });
 public static IPsiSourceFile GetEditorBuildSettings([CanBeNull] UnityExternalFilesPsiModule psiModule)
 {
     return(psiModule?.SourceFiles.FirstOrDefault(t => t.Name.Equals("EditorBuildSettings.asset")));
 }