예제 #1
0
        public static void _SaveTextureAsAsset(string psdPath, UiTreeRoot uiTree)
        {
            string importedTexturesFolder = _GetImportedTexturesSavePath(psdPath);

            _EnsureFolder(importedTexturesFolder);
            string[]      allExistingFilePaths    = Directory.GetFiles(importedTexturesFolder);
            List <string> allExistingFilenameList = allExistingFilePaths.Select(Path.GetFileName).ToList();

            var saveTextureVisitor = new SaveTextureVisitor(importedTexturesFolder);

            saveTextureVisitor.Visit(uiTree);

            var newUiRequiredFilenameList = new List <string>();

            saveTextureVisitor.CreatedTextureFilename.ForEach(createdFilename =>
            {
                newUiRequiredFilenameList.Add(createdFilename);
                newUiRequiredFilenameList.Add(createdFilename + ".meta");
            });
            saveTextureVisitor.ReusedTextureFilename.ForEach(reusedFilename =>
            {
                newUiRequiredFilenameList.Add(reusedFilename);
                newUiRequiredFilenameList.Add(reusedFilename + ".meta");
            });

            foreach (string existingFilename in allExistingFilenameList)
            {
                if (!newUiRequiredFilenameList.Contains(existingFilename, StringComparer.OrdinalIgnoreCase))
                {
                    File.Delete(Path.Combine(importedTexturesFolder, existingFilename));
                }
            }
        }
예제 #2
0
        public static void _SaveTextureAsAsset(string psdPath, UiTreeRoot uiTree)
        {
            string importedTexturesFolder = _GetImportedTexturesSavePath(psdPath);

            _ClearFolder(importedTexturesFolder);

            var saveTextureVisitor = new SaveTextureVisitor(importedTexturesFolder);

            saveTextureVisitor.Visit(uiTree);
        }