Пример #1
0
        private void ApplyImportSetting(BuildTarget target, Model.NodeData node, IEnumerable <PerformGraph.AssetGroups> incoming)
        {
            var referenceImporter = GetReferenceAssetImporter(node, true);
            var configurator      = new ImportSettingsConfigurator(referenceImporter);

            foreach (var ag in incoming)
            {
                foreach (var groupKey in ag.assetGroups.Keys)
                {
                    var assets = ag.assetGroups[groupKey];
                    foreach (var asset in assets)
                    {
                        var  importer         = AssetImporter.GetAtPath(asset.importFrom);
                        bool importerModified = false;
                        if (!configurator.IsEqual(importer, m_overwritePackingTag))
                        {
                            configurator.OverwriteImportSettings(importer);
                            importerModified = true;
                        }
                        if (m_overwritePackingTag)
                        {
                            if (asset.filterType == typeof(UnityEditor.TextureImporter))
                            {
                                var textureImporter = AssetImporter.GetAtPath(asset.importFrom) as TextureImporter;
                                var newTagName      = GetTagName(target, groupKey);
                                if (textureImporter.spritePackingTag != newTagName)
                                {
                                    textureImporter.spritePackingTag = newTagName;
                                    importerModified = true;
                                }
                            }
                        }

                        if (importerModified)
                        {
                            importer.SaveAndReimport();
                            asset.TouchImportAsset();
                        }
                    }
                }
            }
        }
Пример #2
0
        private void ApplyImportSetting(BuildTarget target, Model.NodeData node, IEnumerable <PerformGraph.AssetGroups> incoming)
        {
            var referenceImporter = GetReferenceAssetImporter(node, true);
            var configurator      = new ImportSettingsConfigurator(referenceImporter);

            ConfigurationOption opt;

            opt.keepPackingTag  = !m_overwritePackingTag;
            opt.keepSpriteSheet = !m_overwriteSpriteSheet;

            foreach (var ag in incoming)
            {
                foreach (var groupKey in ag.assetGroups.Keys)
                {
                    var assets = ag.assetGroups[groupKey];
                    foreach (var asset in assets)
                    {
                        var  importer         = AssetImporter.GetAtPath(asset.importFrom);
                        bool importerModified = false;
                        opt.customPackingTag = GetTagName(target, groupKey);

                        if (!configurator.IsEqual(importer, opt))
                        {
                            configurator.OverwriteImportSettings(importer, opt);
                            importerModified = true;
                        }

                        if (importerModified)
                        {
                            importer.SaveAndReimport();
                            asset.TouchImportAsset();
                        }
                    }
                }
            }
        }