Exemplo n.º 1
0
        private void OverwriteImportSettings(AudioImporter target, AudioImporter reference)
        {
            target.defaultSampleSettings = reference.defaultSampleSettings;
            target.forceToMono           = reference.forceToMono;
            target.preloadAudioData      = reference.preloadAudioData;

            foreach (var g in NodeGUIUtility.SupportedBuildTargetGroups)
            {
                var platformName = BuildTargetUtility.TargetToAssetBundlePlatformName(g,
                                                                                      BuildTargetUtility.PlatformNameType.AudioImporter);

                if (reference.ContainsSampleSettingsOverride(platformName))
                {
                    var setting = reference.GetOverrideSampleSettings(platformName);
                    if (!target.SetOverrideSampleSettings(platformName, setting))
                    {
                        LogUtility.Logger.LogError("AudioImporter",
                                                   string.Format("Failed to set override setting for {0}: {1}", platformName, target.assetPath));
                    }
                }
                else
                {
                    target.ClearSampleSettingOverride(platformName);
                }
            }

            target.loadInBackground = reference.loadInBackground;
            target.ambisonic        = reference.ambisonic;
        }
        private void OverwriteImportSettings(TextureImporter target, TextureImporter reference, string tagName)
        {
            target.textureType = reference.textureType;

            var targetSetting    = new TextureImporterSettings();
            var referenceSetting = new TextureImporterSettings();

            target.ReadTextureSettings(targetSetting);
            reference.ReadTextureSettings(referenceSetting);

            //以下都是被锁定的图片设置
            targetSetting.aniso = referenceSetting.aniso;
            targetSetting.compressionQuality = referenceSetting.compressionQuality;
            targetSetting.spriteGenerateFallbackPhysicsShape = referenceSetting.spriteGenerateFallbackPhysicsShape;
            targetSetting.spritePixelsPerUnit      = referenceSetting.spritePixelsPerUnit;
            targetSetting.npotScale                = referenceSetting.npotScale;
            targetSetting.readable                 = referenceSetting.readable;
            targetSetting.streamingMipmapsPriority = referenceSetting.streamingMipmapsPriority;
            targetSetting.mipmapEnabled            = referenceSetting.mipmapEnabled;

            target.SetTextureSettings(targetSetting);

            target.androidETC2FallbackOverride = reference.androidETC2FallbackOverride;
            target.anisoLevel               = reference.anisoLevel;
            target.compressionQuality       = reference.compressionQuality;
            target.crunchedCompression      = reference.crunchedCompression;
            target.isReadable               = reference.isReadable;
            target.npotScale                = reference.npotScale;
            target.streamingMipmapsPriority = reference.streamingMipmapsPriority;
            target.streamingMipmaps         = reference.streamingMipmaps;
            target.textureCompression       = reference.textureCompression;
            target.mipmapEnabled            = reference.mipmapEnabled;

            if (m_overwritePackingTag)
            {
                if (!string.IsNullOrEmpty(tagName))
                {
                    target.spritePackingTag = tagName;
                }
                else
                {
                    target.spritePackingTag = reference.spritePackingTag;
                }
            }

            var defaultPlatformSetting = reference.GetDefaultPlatformTextureSettings();

            target.SetPlatformTextureSettings(defaultPlatformSetting);

            foreach (var g in NodeGUIUtility.SupportedBuildTargetGroups)
            {
                var platformName = BuildTargetUtility.TargetToAssetBundlePlatformName(g, BuildTargetUtility.PlatformNameType.TextureImporter);
                var impSet       = reference.GetPlatformTextureSettings(platformName);
                target.SetPlatformTextureSettings(impSet);
            }
        }
        private bool IsEqual(AudioImporter target, AudioImporter reference)
        {
            UnityEngine.Assertions.Assert.IsNotNull(reference);

            if (!IsEqualAudioSampleSetting(target.defaultSampleSettings, reference.defaultSampleSettings))
            {
                return(false);
            }

            foreach (var g in NodeGUIUtility.SupportedBuildTargetGroups)
            {
                var platformName = BuildTargetUtility.TargetToAssetBundlePlatformName(g,
                                                                                      BuildTargetUtility.PlatformNameType.AudioImporter);

                if (target.ContainsSampleSettingsOverride(platformName) !=
                    reference.ContainsSampleSettingsOverride(platformName))
                {
                    return(false);
                }
                if (target.ContainsSampleSettingsOverride(platformName))
                {
                    var t = target.GetOverrideSampleSettings(platformName);
                    var r = reference.GetOverrideSampleSettings(platformName);
                    if (!IsEqualAudioSampleSetting(t, r))
                    {
                        return(false);
                    }
                }
            }

            if (target.forceToMono != reference.forceToMono)
            {
                return(false);
            }
            if (target.loadInBackground != reference.loadInBackground)
            {
                return(false);
            }

#if UNITY_2017_1_OR_NEWER
            if (target.ambisonic != reference.ambisonic)
            {
                return(false);
            }
#endif
            if (target.preloadAudioData != reference.preloadAudioData)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 4
0
        private string PrepareOutputDirectory(BuildTarget target, Model.NodeData node, bool autoCreate, bool throwException)
        {
            var outputOption = (OutputOption)m_outputOption [target];

            if (outputOption == OutputOption.BuildInCacheDirectory)
            {
                return(FileUtility.EnsureAssetBundleCacheDirExists(target, node));
            }

            var outputDir = m_outputDir [target];

            outputDir = outputDir.Replace("{Platform}", BuildTargetUtility.TargetToAssetBundlePlatformName(target));

            if (throwException)
            {
                if (string.IsNullOrEmpty(outputDir))
                {
                    throw new NodeException("Output directory is empty.",
                                            "Select valid output directory from inspector.", node);
                }

                if (target != BuildTargetUtility.GroupToTarget(BuildTargetGroup.Unknown) &&
                    outputOption == OutputOption.ErrorIfNoOutputDirectoryFound)
                {
                    if (!Directory.Exists(outputDir))
                    {
                        throw new NodeException("Output directory not found. \n" + outputDir,
                                                "Create output directory or select other valid directory from inspector.", node);
                    }
                }
            }

            if (autoCreate)
            {
                if (outputOption == OutputOption.DeleteAndRecreateOutputDirectory)
                {
                    if (Directory.Exists(outputDir))
                    {
                        FileUtility.DeleteDirectory(outputDir, true);
                    }
                }

                if (!Directory.Exists(outputDir))
                {
                    Directory.CreateDirectory(outputDir);
                }
            }

            return(outputDir);
        }
Exemplo n.º 5
0
        private static void OverwriteImportSettings(VideoClipImporter target, VideoClipImporter reference)
        {
            target.defaultTargetSettings = reference.defaultTargetSettings;
            target.deinterlaceMode       = reference.deinterlaceMode;
            target.flipHorizontal        = reference.flipHorizontal;
            target.flipVertical          = reference.flipVertical;
            target.importAudio           = reference.importAudio;
            target.keepAlpha             = reference.keepAlpha;

            #if !UNITY_2019_3_OR_NEWER
            target.linearColor       = reference.linearColor;
            target.quality           = reference.quality;
            target.useLegacyImporter = reference.useLegacyImporter;
            #endif

            foreach (var g in NodeGUIUtility.SupportedBuildTargetGroups)
            {
                var platformName = BuildTargetUtility.TargetToAssetBundlePlatformName(g,
                                                                                      BuildTargetUtility.PlatformNameType.VideoClipImporter);

                try {
                    var setting = reference.GetTargetSettings(platformName);
                    if (setting != null)
                    {
                        target.SetTargetSettings(platformName, setting);
                    }
                    else
                    {
                        target.ClearTargetSettings(platformName);
                    }
                } catch (Exception e) {
                    LogUtility.Logger.LogWarning("VideoClipImporter",
                                                 $"Failed to set override setting for platform {platformName}: file :{target.assetPath} \\nreason:{e.Message}");
                }
            }

            /* read only */

            /*
             * importer.frameCount
             * importer.frameRate
             * importer.isPlayingPreview
             * importer.outputFileSize
             * importer.sourceAudioTrackCount
             * importer.sourceFileSize
             * importer.sourceHasAlpha
             * importer.pixelAspectRatioDenominator
             * importer.pixelAspectRatioNumerator
             */
        }
        private string GetPackageNameForGroup(BuildTarget target, string groupKey)
        {
            var exportPackageName = m_packageName[target];
            var packageName       = string.IsNullOrEmpty(exportPackageName) ? groupKey :
                                    exportPackageName.
                                    Replace("{GroupName}", groupKey).
                                    Replace("{Platform}", BuildTargetUtility.TargetToAssetBundlePlatformName(target));

            if (!packageName.EndsWith(".unitypackage"))
            {
                packageName += ".unitypackage";
            }
            return(packageName);
        }
        private void OverwriteImportSettings(TextureImporter target, TextureImporter reference, string tagName)
        {
            target.textureType = reference.textureType;

            var dstSettings = new TextureImporterSettings();
            var srcSettings = new TextureImporterSettings();

            target.ReadTextureSettings(srcSettings);
            reference.ReadTextureSettings(dstSettings);

            if (!m_overwriteSpriteSheet)
            {
                dstSettings.spriteAlignment          = srcSettings.spriteAlignment;
                dstSettings.spriteBorder             = srcSettings.spriteBorder;
                dstSettings.spriteExtrude            = srcSettings.spriteExtrude;
                dstSettings.spriteMode               = srcSettings.spriteMode;
                dstSettings.spriteMeshType           = srcSettings.spriteMeshType;
                dstSettings.spritePivot              = srcSettings.spritePivot;
                dstSettings.spritePixelsPerUnit      = srcSettings.spritePixelsPerUnit;
                dstSettings.spriteTessellationDetail = srcSettings.spriteTessellationDetail;
            }

            target.SetTextureSettings(dstSettings);

            if (m_overwriteSpriteSheet)
            {
                target.spritesheet = reference.spritesheet;
            }

            // some unity version do not properly copy properties via TextureSettings,
            // so also perform manual copy
            target.allowAlphaSplitting         = reference.allowAlphaSplitting;
            target.alphaIsTransparency         = reference.alphaIsTransparency;
            target.alphaSource                 = reference.alphaSource;
            target.alphaTestReferenceValue     = reference.alphaTestReferenceValue;
            target.androidETC2FallbackOverride = reference.androidETC2FallbackOverride;
            target.anisoLevel               = reference.anisoLevel;
            target.borderMipmap             = reference.borderMipmap;
            target.compressionQuality       = reference.compressionQuality;
            target.convertToNormalmap       = reference.convertToNormalmap;
            target.crunchedCompression      = reference.crunchedCompression;
            target.fadeout                  = reference.fadeout;
            target.filterMode               = reference.filterMode;
            target.generateCubemap          = reference.generateCubemap;
            target.heightmapScale           = reference.heightmapScale;
            target.isReadable               = reference.isReadable;
            target.maxTextureSize           = reference.maxTextureSize;
            target.mipMapBias               = reference.mipMapBias;
            target.mipmapEnabled            = reference.mipmapEnabled;
            target.mipmapFadeDistanceEnd    = reference.mipmapFadeDistanceEnd;
            target.mipmapFadeDistanceStart  = reference.mipmapFadeDistanceStart;
            target.mipmapFilter             = reference.mipmapFilter;
            target.mipMapsPreserveCoverage  = reference.mipMapsPreserveCoverage;
            target.normalmapFilter          = reference.normalmapFilter;
            target.npotScale                = reference.npotScale;
            target.sRGBTexture              = reference.sRGBTexture;
            target.streamingMipmaps         = reference.streamingMipmaps;
            target.streamingMipmapsPriority = reference.streamingMipmapsPriority;
            target.textureCompression       = reference.textureCompression;
            target.textureShape             = reference.textureShape;
            target.wrapMode                 = reference.wrapMode;
            target.wrapModeU                = reference.wrapModeU;
            target.wrapModeV                = reference.wrapModeV;
            target.wrapModeW                = reference.wrapModeW;

            if (m_overwritePackingTag)
            {
                if (!string.IsNullOrEmpty(tagName))
                {
                    target.spritePackingTag = tagName;
                }
                else
                {
                    target.spritePackingTag = reference.spritePackingTag;
                }
            }

            var defaultPlatformSetting = reference.GetDefaultPlatformTextureSettings();

            target.SetPlatformTextureSettings(defaultPlatformSetting);

            foreach (var g in NodeGUIUtility.SupportedBuildTargetGroups)
            {
                var platformName = BuildTargetUtility.TargetToAssetBundlePlatformName(g, BuildTargetUtility.PlatformNameType.TextureImporter);
                var impSet       = reference.GetPlatformTextureSettings(platformName);
                target.SetPlatformTextureSettings(impSet);
            }
        }
        private bool IsEqual(TextureImporter target, TextureImporter reference, string tagName)
        {
            // UnityEditor.TextureImporter.textureFormat' is obsolete:
            // `textureFormat is not longer accessible at the TextureImporter level
            if (target.textureType != reference.textureType)
            {
                return(false);
            }

            TextureImporterSettings targetSetting    = new TextureImporterSettings();
            TextureImporterSettings referenceSetting = new TextureImporterSettings();

            target.ReadTextureSettings(targetSetting);
            reference.ReadTextureSettings(referenceSetting);

            // if m_overwriteSpriteSheet is false, following properties
            // should be ignored
            if (!m_overwriteSpriteSheet)
            {
                referenceSetting.spriteAlignment          = targetSetting.spriteAlignment;
                referenceSetting.spriteBorder             = targetSetting.spriteBorder;
                referenceSetting.spriteExtrude            = targetSetting.spriteExtrude;
                referenceSetting.spriteMode               = targetSetting.spriteMode;
                referenceSetting.spriteMeshType           = targetSetting.spriteMeshType;
                referenceSetting.spritePivot              = targetSetting.spritePivot;
                referenceSetting.spritePixelsPerUnit      = targetSetting.spritePixelsPerUnit;
                referenceSetting.spriteTessellationDetail = targetSetting.spriteTessellationDetail;
            }

            if (!TextureImporterSettings.Equal(targetSetting, referenceSetting))
            {
                return(false);
            }

            if (target.textureType == TextureImporterType.Sprite)
            {
                if (m_overwritePackingTag)
                {
                    if (!string.IsNullOrEmpty(tagName))
                    {
                        if (target.spritePackingTag != tagName)
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        if (target.spritePackingTag != reference.spritePackingTag)
                        {
                            return(false);
                        }
                    }
                }

                if (m_overwriteSpriteSheet)
                {
                    if (target.spriteBorder != reference.spriteBorder)
                    {
                        return(false);
                    }
                    if (target.spriteImportMode != reference.spriteImportMode)
                    {
                        return(false);
                    }
                    if (target.spritePivot != reference.spritePivot)
                    {
                        return(false);
                    }
                    if (target.spritePixelsPerUnit != reference.spritePixelsPerUnit)
                    {
                        return(false);
                    }

                    var s1 = target.spritesheet;
                    var s2 = reference.spritesheet;

                    if (s1.Length != s2.Length)
                    {
                        return(false);
                    }

                    for (int i = 0; i < s1.Length; ++i)
                    {
                        if (s1 [i].alignment != s2 [i].alignment)
                        {
                            return(false);
                        }
                        if (s1 [i].border != s2 [i].border)
                        {
                            return(false);
                        }
                        if (s1 [i].name != s2 [i].name)
                        {
                            return(false);
                        }
                        if (s1 [i].pivot != s2 [i].pivot)
                        {
                            return(false);
                        }
                        if (s1 [i].rect != s2 [i].rect)
                        {
                            return(false);
                        }
                    }
                }
            }

            if (target.allowAlphaSplitting != reference.allowAlphaSplitting)
            {
                return(false);
            }
            if (target.alphaIsTransparency != reference.alphaIsTransparency)
            {
                return(false);
            }
            if (target.alphaSource != reference.alphaSource)
            {
                return(false);
            }
            if (target.alphaTestReferenceValue != reference.alphaTestReferenceValue)
            {
                return(false);
            }
            if (target.androidETC2FallbackOverride != reference.androidETC2FallbackOverride)
            {
                return(false);
            }
            if (target.anisoLevel != reference.anisoLevel)
            {
                return(false);
            }
            if (target.borderMipmap != reference.borderMipmap)
            {
                return(false);
            }
            if (target.compressionQuality != reference.compressionQuality)
            {
                return(false);
            }
            if (target.convertToNormalmap != reference.convertToNormalmap)
            {
                return(false);
            }
            if (target.crunchedCompression != reference.crunchedCompression)
            {
                return(false);
            }
            if (target.fadeout != reference.fadeout)
            {
                return(false);
            }
            if (target.filterMode != reference.filterMode)
            {
                return(false);
            }
            if (target.generateCubemap != reference.generateCubemap)
            {
                return(false);
            }
            if (target.heightmapScale != reference.heightmapScale)
            {
                return(false);
            }
            if (target.isReadable != reference.isReadable)
            {
                return(false);
            }
            if (target.maxTextureSize != reference.maxTextureSize)
            {
                return(false);
            }
            if (target.mipMapBias != reference.mipMapBias)
            {
                return(false);
            }
            if (target.mipmapEnabled != reference.mipmapEnabled)
            {
                return(false);
            }
            if (target.mipmapFadeDistanceEnd != reference.mipmapFadeDistanceEnd)
            {
                return(false);
            }
            if (target.mipmapFadeDistanceStart != reference.mipmapFadeDistanceStart)
            {
                return(false);
            }
            if (target.mipmapFilter != reference.mipmapFilter)
            {
                return(false);
            }
            if (target.mipMapsPreserveCoverage != reference.mipMapsPreserveCoverage)
            {
                return(false);
            }
            if (target.normalmapFilter != reference.normalmapFilter)
            {
                return(false);
            }
            if (target.npotScale != reference.npotScale)
            {
                return(false);
            }

            if (target.sRGBTexture != reference.sRGBTexture)
            {
                return(false);
            }
            if (target.streamingMipmaps != reference.streamingMipmaps)
            {
                return(false);
            }
            if (target.streamingMipmapsPriority != reference.streamingMipmapsPriority)
            {
                return(false);
            }
            if (target.textureCompression != reference.textureCompression)
            {
                return(false);
            }
            if (target.textureShape != reference.textureShape)
            {
                return(false);
            }
            if (target.wrapMode != reference.wrapMode)
            {
                return(false);
            }
            if (target.wrapModeU != reference.wrapModeU)
            {
                return(false);
            }
            if (target.wrapModeV != reference.wrapModeV)
            {
                return(false);
            }
            if (target.wrapModeW != reference.wrapModeW)
            {
                return(false);
            }

            var refDefault = reference.GetDefaultPlatformTextureSettings();
            var impDefault = target.GetDefaultPlatformTextureSettings();

            if (!CompareImporterPlatformSettings(refDefault, impDefault))
            {
                return(false);
            }

            foreach (var g in NodeGUIUtility.SupportedBuildTargetGroups)
            {
                var platformName = BuildTargetUtility.TargetToAssetBundlePlatformName(g, BuildTargetUtility.PlatformNameType.TextureImporter);

                var impSet       = reference.GetPlatformTextureSettings(platformName);
                var targetImpSet = target.GetPlatformTextureSettings(platformName);
                if (!CompareImporterPlatformSettings(impSet, targetImpSet))
                {
                    return(false);
                }
            }


            return(true);
        }
        public bool IsEqual(VideoClipImporter target, VideoClipImporter reference)
        {
            if (!CompareVideoImporterTargetSettings(target.defaultTargetSettings, reference.defaultTargetSettings))
            {
                return(false);
            }

            /* read only properties. ImportSettingConfigurator will not use these properties for diff. */

            /*
             * importer.frameCount
             * importer.frameRate
             * importer.isPlayingPreview
             * importer.outputFileSize
             * importer.sourceAudioTrackCount
             * importer.sourceFileSize
             * importer.sourceHasAlpha
             */

            if (target.deinterlaceMode != reference.deinterlaceMode)
            {
                return(false);
            }
            if (target.flipHorizontal != reference.flipHorizontal)
            {
                return(false);
            }
            if (target.flipVertical != reference.flipVertical)
            {
                return(false);
            }
            if (target.importAudio != reference.importAudio)
            {
                return(false);
            }
            if (target.keepAlpha != reference.keepAlpha)
            {
                return(false);
            }
            if (target.linearColor != reference.linearColor)
            {
                return(false);
            }
            if (target.quality != reference.quality)
            {
                return(false);
            }
            if (target.useLegacyImporter != reference.useLegacyImporter)
            {
                return(false);
            }

            #if UNITY_2017_2_OR_NEWER
            if (target.pixelAspectRatioDenominator != reference.pixelAspectRatioDenominator)
            {
                return(false);
            }
            if (target.pixelAspectRatioNumerator != reference.pixelAspectRatioNumerator)
            {
                return(false);
            }
            #endif

            foreach (var g in NodeGUIUtility.SupportedBuildTargetGroups)
            {
                var platformName = BuildTargetUtility.TargetToAssetBundlePlatformName(g,
                                                                                      BuildTargetUtility.PlatformNameType.VideoClipImporter);

                try {
                    var r = reference.GetTargetSettings(platformName);
                    var t = target.GetTargetSettings(platformName);

                    // if both targets are null - keep going
                    if (r == null && t == null)
                    {
                        continue;
                    }

                    if (r == null || t == null)
                    {
                        return(false);
                    }

                    if (!CompareVideoImporterTargetSettings(r, t))
                    {
                        return(false);
                    }
                } catch (Exception e) {
                    LogUtility.Logger.LogError("VideoClipImporter",
                                               string.Format("Failed to test equality setting for {0}: file :{1} type:{3} reason:{2}",
                                                             platformName, target.assetPath, e.Message, e.GetType().ToString()));
                }
            }

            return(true);
        }
        private void OverwriteImportSettings(VideoClipImporter target, VideoClipImporter reference)
        {
            /*
             * defaultTargetSettings   Default values for the platform-specific import settings.
             * deinterlaceMode         Images are deinterlaced during transcode. This tells the importer how to interpret fields in the source, if any.
             * flipHorizontal          Apply a horizontal flip during import.
             * flipVertical            Apply a vertical flip during import.
             * frameCount              Number of frames in the clip.
             * frameRate               Frame rate of the clip.
             * importAudio             Import audio tracks from source file.
             * isPlayingPreview        Whether the preview is currently playing.
             * keepAlpha               Whether to keep the alpha from the source into the transcoded clip.
             * linearColor             Used in legacy import mode. Same as MovieImport.linearTexture.
             * outputFileSize          Size in bytes of the file once imported.
             * quality                 Used in legacy import mode. Same as MovieImport.quality.
             * sourceAudioTrackCount   Number of audio tracks in the source file.
             * sourceFileSize          Size in bytes of the file before importing.
             * sourceHasAlpha          True if the source file has a channel for per-pixel transparency.
             * useLegacyImporter       Whether to import a MovieTexture (legacy) or a VideoClip.
             */

            target.defaultTargetSettings = reference.defaultTargetSettings;
            target.deinterlaceMode       = reference.deinterlaceMode;
            target.flipHorizontal        = reference.flipHorizontal;
            target.flipVertical          = reference.flipVertical;
            target.importAudio           = reference.importAudio;
            target.keepAlpha             = reference.keepAlpha;
            target.linearColor           = reference.linearColor;
            target.quality           = reference.quality;
            target.useLegacyImporter = reference.useLegacyImporter;

            foreach (var g in NodeGUIUtility.SupportedBuildTargetGroups)
            {
                var platformName = BuildTargetUtility.TargetToAssetBundlePlatformName(g,
                                                                                      BuildTargetUtility.PlatformNameType.VideoClipImporter);

                try {
                    var setting = reference.GetTargetSettings(platformName);
                    if (setting != null)
                    {
                        target.SetTargetSettings(platformName, setting);
                    }
                    else
                    {
                        target.ClearTargetSettings(platformName);
                    }
                } catch (Exception e) {
                    LogUtility.Logger.LogWarning("VideoClipImporter",
                                                 string.Format("Failed to set override setting for platform {0}: file :{1} \\nreason:{2}",
                                                               platformName, target.assetPath, e.Message));
                }
            }

            /* read only */

            /*
             * importer.frameCount
             * importer.frameRate
             * importer.isPlayingPreview
             * importer.outputFileSize
             * importer.sourceAudioTrackCount
             * importer.sourceFileSize
             * importer.sourceHasAlpha
             * importer.pixelAspectRatioDenominator
             * importer.pixelAspectRatioNumerator
             */
        }
Exemplo n.º 11
0
        public static string EnsureAssetBundleCacheDirExists(BuildTarget t, Model.NodeData node, bool remake = false)
        {
            var cacheDir = FileUtility.PathCombine(Model.Settings.Path.BundleBuilderCachePath, node.Id, BuildTargetUtility.TargetToAssetBundlePlatformName(t));

            if (!Directory.Exists(cacheDir))
            {
                Directory.CreateDirectory(cacheDir);
            }
            else
            {
                if (remake)
                {
                    RemakeDirectory(cacheDir);
                }
            }
            return(cacheDir);
        }
        private bool IsEqual(TextureImporter target, TextureImporter reference, string tagName)
        {
            // UnityEditor.TextureImporter.textureFormat' is obsolete:
            // `textureFormat is not longer accessible at the TextureImporter level
            if (target == null)
            {
                //空资源跳过不设置
                return(false);
            }

            if (reference == null || target.textureType != reference.textureType)
            {
                return(false);
            }

            TextureImporterSettings targetSetting    = new TextureImporterSettings();
            TextureImporterSettings referenceSetting = new TextureImporterSettings();

            target.ReadTextureSettings(targetSetting);
            reference.ReadTextureSettings(referenceSetting);


            if (targetSetting.aniso != referenceSetting.aniso)
            {
                return(false);
            }
            if (targetSetting.compressionQuality != referenceSetting.compressionQuality)
            {
                return(false);
            }
            if (targetSetting.spriteGenerateFallbackPhysicsShape != referenceSetting.spriteGenerateFallbackPhysicsShape)
            {
                return(false);
            }
            if (targetSetting.spritePixelsPerUnit != referenceSetting.spritePixelsPerUnit)
            {
                return(false);
            }
            if (targetSetting.npotScale != referenceSetting.npotScale)
            {
                return(false);
            }
            if (targetSetting.readable != referenceSetting.readable)
            {
                return(false);
            }
            if (targetSetting.streamingMipmapsPriority != referenceSetting.streamingMipmapsPriority)
            {
                return(false);
            }
            if (targetSetting.mipmapEnabled != referenceSetting.mipmapEnabled)
            {
                return(false);
            }
            if (m_overwritePackingTag)
            {
                if (target.spritePackingTag != reference.spritePackingTag)
                {
                    return(false);
                }
            }


            if (target.androidETC2FallbackOverride != reference.androidETC2FallbackOverride)
            {
                return(false);
            }
            if (target.compressionQuality != reference.compressionQuality)
            {
                return(false);
            }
            if (target.crunchedCompression != reference.crunchedCompression)
            {
                return(false);
            }
            if (target.isReadable != reference.isReadable)
            {
                return(false);
            }
            if (target.npotScale != reference.npotScale)
            {
                return(false);
            }
            if (target.streamingMipmaps != reference.streamingMipmaps)
            {
                return(false);
            }
            if (target.streamingMipmapsPriority != reference.streamingMipmapsPriority)
            {
                return(false);
            }
            if (target.textureCompression != reference.textureCompression)
            {
                return(false);
            }
            if (target.mipmapEnabled != reference.mipmapEnabled)
            {
                return(false);
            }


            var refDefault = reference.GetDefaultPlatformTextureSettings();
            var impDefault = target.GetDefaultPlatformTextureSettings();

            if (!CompareImporterPlatformSettings(refDefault, impDefault))
            {
                return(false);
            }

            foreach (var g in NodeGUIUtility.SupportedBuildTargetGroups)
            {
                var platformName = BuildTargetUtility.TargetToAssetBundlePlatformName(g, BuildTargetUtility.PlatformNameType.TextureImporter);

                var impSet       = reference.GetPlatformTextureSettings(platformName);
                var targetImpSet = target.GetPlatformTextureSettings(platformName);
                if (!CompareImporterPlatformSettings(impSet, targetImpSet))
                {
                    return(false);
                }
            }


            return(true);
        }
Exemplo n.º 13
0
        private void OverwriteImportSettings(TextureImporter target, TextureImporter reference, string tagName)
        {
            target.textureType = reference.textureType;

            TextureImporterSettings dstSettings = new TextureImporterSettings();
            TextureImporterSettings srcSettings = new TextureImporterSettings();

            target.ReadTextureSettings(srcSettings);
            reference.ReadTextureSettings(dstSettings);

            if (!m_overwriteSpriteSheet)
            {
                dstSettings.spriteAlignment          = srcSettings.spriteAlignment;
                dstSettings.spriteBorder             = srcSettings.spriteBorder;
                dstSettings.spriteExtrude            = srcSettings.spriteExtrude;
                dstSettings.spriteMode               = srcSettings.spriteMode;
                dstSettings.spriteMeshType           = srcSettings.spriteMeshType;
                dstSettings.spritePivot              = srcSettings.spritePivot;
                dstSettings.spritePixelsPerUnit      = srcSettings.spritePixelsPerUnit;
                dstSettings.spriteTessellationDetail = srcSettings.spriteTessellationDetail;
            }

            target.SetTextureSettings(dstSettings);

            if (m_overwriteSpriteSheet)
            {
                target.spritesheet = reference.spritesheet;
            }

            // some unity version do not properly copy properties via TextureSettings,
            // so also perform manual copy

            target.anisoLevel         = reference.anisoLevel;
            target.borderMipmap       = reference.borderMipmap;
            target.compressionQuality = reference.compressionQuality;
            target.convertToNormalmap = reference.convertToNormalmap;
            target.fadeout            = reference.fadeout;
            target.filterMode         = reference.filterMode;
            target.generateCubemap    = reference.generateCubemap;
            target.heightmapScale     = reference.heightmapScale;

            target.isReadable              = reference.isReadable;
            target.maxTextureSize          = reference.maxTextureSize;
            target.mipMapBias              = reference.mipMapBias;
            target.mipmapEnabled           = reference.mipmapEnabled;
            target.mipmapFadeDistanceEnd   = reference.mipmapFadeDistanceEnd;
            target.mipmapFadeDistanceStart = reference.mipmapFadeDistanceStart;
            target.mipmapFilter            = reference.mipmapFilter;

            target.normalmapFilter = reference.normalmapFilter;
            target.npotScale       = reference.npotScale;

            if (m_overwritePackingTag)
            {
                if (!string.IsNullOrEmpty(tagName))
                {
                    target.spritePackingTag = tagName;
                }
                else
                {
                    target.spritePackingTag = reference.spritePackingTag;
                }
            }

            target.wrapMode = reference.wrapMode;

            /* read only */
            // importer.qualifiesForSpritePacking

#if !UNITY_5_5_OR_NEWER
            // obsolete features
            importer.generateMipsInLinearSpace = reference.generateMipsInLinearSpace;
            importer.grayscaleToAlpha          = reference.grayscaleToAlpha;
            importer.lightmap      = reference.lightmap;
            importer.linearTexture = reference.linearTexture;
            importer.normalmap     = reference.normalmap;
            importer.textureFormat = reference.textureFormat;

            foreach (var g in NodeGUIUtility.SupportedBuildTargetGroups)
            {
                var platformName = BuildTargetUtility.TargetToAssetBundlePlatformName(g, BuildTargetUtility.PlatformNameType.TextureImporter);

                int maxTextureSize;
                TextureImporterFormat format;
                int compressionQuality;

                if (reference.GetPlatformTextureSettings(platformName, out maxTextureSize, out format, out compressionQuality))
                {
                    importer.SetPlatformTextureSettings(platformName, maxTextureSize, format, compressionQuality, false);
                }
                else
                {
                    importer.ClearPlatformTextureSettings(platformName);
                }
            }
#else
            target.allowAlphaSplitting = reference.allowAlphaSplitting;
            target.alphaIsTransparency = reference.alphaIsTransparency;
            target.textureShape        = reference.textureShape;

            target.alphaSource         = reference.alphaSource;
            target.sRGBTexture         = reference.sRGBTexture;
            target.textureCompression  = reference.textureCompression;
            target.crunchedCompression = reference.crunchedCompression;

            var defaultPlatformSetting = reference.GetDefaultPlatformTextureSettings();
            target.SetPlatformTextureSettings(defaultPlatformSetting);

            foreach (var g in NodeGUIUtility.SupportedBuildTargetGroups)
            {
                var platformName = BuildTargetUtility.TargetToAssetBundlePlatformName(g, BuildTargetUtility.PlatformNameType.TextureImporter);
                var impSet       = reference.GetPlatformTextureSettings(platformName);
                target.SetPlatformTextureSettings(impSet);
            }
#endif

#if UNITY_2017_1_OR_NEWER
            target.alphaTestReferenceValue = reference.alphaTestReferenceValue;
            target.mipMapsPreserveCoverage = reference.mipMapsPreserveCoverage;
            target.wrapModeU = reference.wrapModeU;
            target.wrapModeV = reference.wrapModeV;
            target.wrapModeW = reference.wrapModeW;
#endif
        }