public TextureMipmapSettings(TextureImporterMipFilter filter, bool borderMipmap, bool fadeout, bool preserveCoverage, int fadeDistanceStart, int fadeDistanceEnd) { this.filter = filter; this.borderMipmap = borderMipmap; this.fadeout = fadeout; this.preserveCoverage = preserveCoverage; this.fadeDistanceStart = fadeDistanceStart; this.fadeDistanceEnd = fadeDistanceEnd; }
private static bool SetMipmapFilter(TextureImporter im, TextureImporterMipFilter value) { bool rt = false; if (im.mipmapFilter != value) { rt = true; im.mipmapFilter = value; Debug.Log("SetMipmapFilter succ:" + im.assetPath + " " + value); } return(rt); }
public override void ReadFromAsset(Object asset) { if (!(asset is Texture2D)) { Debug.Log("Asset isn't a Texture2D. Can't read from asset"); return; } Texture2D texture = asset as Texture2D; name = texture.name; TextureImporter textureImporter = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(texture)) as TextureImporter; if (textureImporter == null) { Debug.Log("Could not get texture importer for asset at path: " + AssetDatabase.GetAssetPath(texture)); return; } guid = AssetDatabase.AssetPathToGUID(textureImporter.assetPath); anisoLevel = textureImporter.anisoLevel; borderMipmap = textureImporter.borderMipmap; convertToNormalmap = textureImporter.convertToNormalmap; generateMipsInLinearSpace = textureImporter.generateMipsInLinearSpace; fadeout = textureImporter.fadeout; filterMode = textureImporter.filterMode; generateCubemap = textureImporter.generateCubemap; grayscaleToAlpha = textureImporter.grayscaleToAlpha; heightmapScale = textureImporter.heightmapScale; isReadable = textureImporter.isReadable; lightmap = textureImporter.lightmap; maxTextureSize = textureImporter.maxTextureSize; mipMapBias = textureImporter.mipMapBias; mipmapEnabled = textureImporter.mipmapEnabled; mipmapFadeDistanceEnd = textureImporter.mipmapFadeDistanceEnd; mipmapFadeDistanceStart = textureImporter.mipmapFadeDistanceStart; mipmapFilter = textureImporter.mipmapFilter; normalmap = textureImporter.normalmap; normalmapFilter = textureImporter.normalmapFilter; npotScale = textureImporter.npotScale; textureFormat = textureImporter.textureFormat; textureType = textureImporter.textureType; wrapMode = textureImporter.wrapMode; }
private void Revert() { textureType = TextureImporterType.Image; grayscaleToAlpha = false; alphaIsTransparency = false; wrapMode = TextureWrapMode.Repeat; filterMode = FilterMode.Bilinear; anisoLevel = 1; createFromGrayscale = true; bumpiness = 0.25f; filtering = 0; spriteMode = SpriteImportMode.Single; packingTag = ""; pixelsToUnits = 100; meshType = SpriteMeshType.Tight; extrudeEdges = 1; pivot = 505; pivotX = 0.5f; pivotY = 0.5f; mapping = 4; fixupEdgeSeams = false; lightType = LightType.Spot; nonPowerOf2 = TextureImporterNPOTScale.ToNearest; generateCubemap = TextureImporterGenerateCubemap.None; readWriteEnabled = false; importType = 0; bypassSRGBSampling = false; generateMipMaps = true; inLinearSpace = false; borderMipMaps = false; mipMapFiltering = TextureImporterMipFilter.BoxFilter; fadeoutMipMaps = false; fadeoutMin = 1; fadeoutMax = 3; for (int i = 0, length = textureFormats.Length; i < length; i++) { textureFormats[i] = TextureImporterFormat.AutomaticCompressed; } for (int i = 0, length = compressionQualitys.Length; i < length; i++) { compressionQualitys[i] = (int)TextureCompressionQuality.Normal; } }
public void Apply(TextureImporterSettings settings) { this.seamlessCubemap = settings.seamlessCubemap; this.mipmapBias = settings.mipmapBias; this.wrapMode = settings.wrapMode; this.wrapModeU = settings.wrapModeU; this.wrapModeV = settings.wrapModeV; this.wrapModeW = settings.wrapModeW; this.alphaIsTransparency = settings.alphaIsTransparency; this.spriteMode = settings.spriteMode; this.spritePixelsPerUnit = settings.spritePixelsPerUnit; this.spriteTessellationDetail = settings.spriteTessellationDetail; this.spriteExtrude = settings.spriteExtrude; this.spriteMeshType = settings.spriteMeshType; this.spriteAlignment = settings.spriteAlignment; this.spritePivot = settings.spritePivot; this.spriteBorder = settings.spriteBorder; this.spriteGenerateFallbackPhysicsShape = settings.spriteGenerateFallbackPhysicsShape; this.aniso = settings.aniso; this.filterMode = settings.filterMode; this.cubemapConvolution = settings.cubemapConvolution; this.textureType = settings.textureType; this.textureShape = settings.textureShape; this.mipmapFilter = settings.mipmapFilter; this.mipmapEnabled = settings.mipmapEnabled; this.sRGBTexture = settings.sRGBTexture; this.fadeOut = settings.fadeOut; this.borderMipmap = settings.borderMipmap; this.mipMapsPreserveCoverage = settings.mipMapsPreserveCoverage; this.mipmapFadeDistanceStart = settings.mipmapFadeDistanceStart; this.alphaTestReferenceValue = settings.alphaTestReferenceValue; this.convertToNormalMap = settings.convertToNormalMap; this.heightmapScale = settings.heightmapScale; this.normalMapFilter = settings.normalMapFilter; this.alphaSource = settings.alphaSource; this.singleChannelComponent = settings.singleChannelComponent; this.readable = settings.readable; this.streamingMipmaps = settings.streamingMipmaps; this.streamingMipmapsPriority = settings.streamingMipmapsPriority; this.npotScale = settings.npotScale; this.generateCubemap = settings.generateCubemap; this.mipmapFadeDistanceEnd = settings.mipmapFadeDistanceEnd; }
private void DisplayAdvancedSettings() { GUILayout.Label("Advanced Settings", EditorStyles.miniBoldLabel); EditorGUI.indentLevel++; nonPowerofTwo = (TextureImporterNPOTScale)EditorGUILayout.EnumPopup("Non Power of 2", nonPowerofTwo); readWriteEnabled = EditorGUILayout.Toggle("Read/Write Enabled", readWriteEnabled); generateMipMaps = EditorGUILayout.Toggle("Generate Mip Maps", generateMipMaps); if (generateMipMaps) { EditorGUI.indentLevel++; borderMipMaps = EditorGUILayout.Toggle("Border Mip Maps", borderMipMaps); mipMapFiltering = (TextureImporterMipFilter)EditorGUILayout.EnumPopup("Mip Map Filtering", mipMapFiltering); fadeoutMipMaps = EditorGUILayout.Toggle("Fadeout Mip Maps", fadeoutMipMaps); EditorGUI.indentLevel--; } EditorGUI.indentLevel--; }
public TextureImportSettings() { textureFormat = TextureImporterFormat.AutomaticTruecolor; maxTextureSize = (int)TextureSize.Unlimited; grayscaleToAlpha = false; generateCubemap = TextureImporterGenerateCubemap.None; isReadable = false; mipmapEnabled = true; borderMipmap = false; mipmapFilter = TextureImporterMipFilter.BoxFilter; fadeout = false; mipmapFadeDistanceStart = 1; mipmapFadeDistanceEnd = 1; generateMipsInLinearSpace = false; normalmapFilter = TextureImporterNormalFilter.Standard; heightmapScale = 0.25f; anisoLevel = 1; filterMode = FilterMode.Bilinear; wrapMode = TextureWrapMode.Repeat; textureType = TextureImporterType.Default; }
private void DrawTextureSettings(TextureImporterType textureType) { if (textureType != oldTextureType) { Reset(); } switch (textureType) { case TextureImporterType.Image: if ((grayscaleToAlpha = EditorGUILayout.Toggle("Alpha from Grayscale", grayscaleToAlpha))) { alphaIsTransparency = EditorGUILayout.Toggle("Alpha is Transparency", alphaIsTransparency); } GUILayout.Space(8f); wrapMode = (TextureWrapMode)DrawPopup("Wrap Mode", (int)wrapMode, wrapModeString); if ((filterMode = (FilterMode)DrawPopup("Filter Mode", (int)filterMode, filterModeString)) != FilterMode.Point) { anisoLevel = EditorGUILayout.IntSlider("Aniso Level", anisoLevel, 0, 9); } break; case TextureImporterType.Bump: if (createFromGrayscale = EditorGUILayout.Toggle("(Invalid) Create from Grayscale", createFromGrayscale)) { bumpiness = EditorGUILayout.Slider("(Invalid) Bumpiness", bumpiness, 0, 0.3f); filtering = DrawPopup("(Invalid) Filtering", filtering, filteringString); } GUILayout.Space(8f); wrapMode = (TextureWrapMode)DrawPopup("Wrap Mode", (int)wrapMode, wrapModeString); if ((filterMode = (FilterMode)DrawPopup("Filter Mode", (int)filterMode, filterModeString)) != FilterMode.Point) { anisoLevel = EditorGUILayout.IntSlider("Aniso Level", anisoLevel, 0, 9); } break; case TextureImporterType.GUI: GUILayout.Space(8f); filterMode = (FilterMode)DrawPopup("Filter Mode", (int)filterMode, filterModeString); break; case TextureImporterType.Sprite: spriteMode = (SpriteImportMode)DrawPopup("Sprite Mode", (int)spriteMode, spriteModeString, spriteModeArray); packingTag = EditorGUILayout.TextField(" Packing Tag", packingTag); pixelsToUnits = EditorGUILayout.FloatField(" Pixels To Units", pixelsToUnits); if (spriteMode == SpriteImportMode.Single) { if ((pivot = DrawPopup(" Pivot", pivot, pivotString, pivotArray)) == -1) { GUILayout.BeginHorizontal(); GUILayout.Space(EditorGUIUtility.labelWidth); GUILayout.Label("X"); pivotX = EditorGUILayout.FloatField(pivotX); GUILayout.Label("Y"); pivotY = EditorGUILayout.FloatField(pivotY); GUILayout.EndHorizontal(); } } GUILayout.Space(8f); filterMode = (FilterMode)DrawPopup("Filter Mode", (int)filterMode, filterModeString); break; case TextureImporterType.Cursor: GUILayout.Space(8f); wrapMode = (TextureWrapMode)DrawPopup("Wrap Mode", (int)wrapMode, wrapModeString); filterMode = (FilterMode)DrawPopup("Filter Mode", (int)filterMode, filterModeString); break; case TextureImporterType.Reflection: mapping = DrawPopup("Mapping", mapping, mappingString); fixupEdgeSeams = EditorGUILayout.Toggle("Fixup Edge Seams", fixupEdgeSeams); GUILayout.Space(8f); if ((filterMode = (FilterMode)DrawPopup("Filter Mode", (int)filterMode, filterModeString)) != FilterMode.Point) { anisoLevel = EditorGUILayout.IntSlider("Aniso Level", anisoLevel, 0, 9); } break; case TextureImporterType.Cookie: if ((lightType = (LightType)DrawPopup("(Invalid) Light Type", (int)lightType, lightTypeString)) == LightType.Point) { mapping = DrawPopup("(Invalid) Mapping", mapping, mappingString); fixupEdgeSeams = EditorGUILayout.Toggle("(Invalid) Fixup Edge Seams", fixupEdgeSeams); } grayscaleToAlpha = EditorGUILayout.Toggle("Alpha from Grayscale", grayscaleToAlpha); GUILayout.Space(8f); if ((filterMode = (FilterMode)DrawPopup("Filter Mode", (int)filterMode, filterModeString)) != FilterMode.Point) { anisoLevel = EditorGUILayout.IntSlider("Aniso Level", anisoLevel, 0, 9); } break; case TextureImporterType.Lightmap: GUILayout.Space(8f); if ((filterMode = (FilterMode)DrawPopup("Filter Mode", (int)filterMode, filterModeString)) != FilterMode.Point) { anisoLevel = EditorGUILayout.IntSlider("Aniso Level", anisoLevel, 0, 9); } break; case TextureImporterType.Advanced: nonPowerOf2 = (TextureImporterNPOTScale)DrawPopup("Non Power of 2", (int)nonPowerOf2, nonPowerOf2String); generateCubemap = (TextureImporterGenerateCubemap)DrawPopup("Generate Cubemap", (int)generateCubemap, generateCubemapString); readWriteEnabled = EditorGUILayout.Toggle("Read/Write Enabled", readWriteEnabled); importType = (TextureImporterType)DrawPopup("Import Type", (int)importType, importTypeString, importTypeArray); if (importType == TextureImporterType.Image) { grayscaleToAlpha = EditorGUILayout.Toggle(" Alpha from Grayscale", grayscaleToAlpha); alphaIsTransparency = EditorGUILayout.Toggle(" Alpha is Transparency", alphaIsTransparency); bypassSRGBSampling = EditorGUILayout.Toggle(" (Invalid) Bypass sRGB Sampling", bypassSRGBSampling); spriteMode = (SpriteImportMode)DrawPopup(" Sprite Mode", (int)spriteMode, spriteModeStringFull); if (spriteMode != SpriteImportMode.None) { packingTag = EditorGUILayout.TextField(" Packing Tag", packingTag); pixelsToUnits = EditorGUILayout.FloatField(" Pixels To Units", pixelsToUnits); meshType = (SpriteMeshType)DrawPopup(" Mesh Type", (int)meshType, meshTypeString); extrudeEdges = (uint)EditorGUILayout.IntSlider(" Extrude Edges", (int)extrudeEdges, 0, 32); if (spriteMode == SpriteImportMode.Single) { if ((pivot = DrawPopup(" Pivot", pivot, pivotString, pivotArray)) == -1) { GUILayout.BeginHorizontal(); GUILayout.Space(EditorGUIUtility.labelWidth); GUILayout.Label("X"); pivotX = EditorGUILayout.FloatField(pivotX); GUILayout.Label("Y"); pivotY = EditorGUILayout.FloatField(pivotY); GUILayout.EndHorizontal(); } } } } else if (importType == TextureImporterType.Bump) { if (createFromGrayscale = EditorGUILayout.Toggle(" (Invalid) Create from Grayscale", createFromGrayscale)) { bumpiness = EditorGUILayout.Slider(" (Invalid) Bumpiness", bumpiness, 0, 0.3f); filtering = DrawPopup(" Filtering", filtering, filteringString); } } GUILayout.Space(8f); if (generateMipMaps = EditorGUILayout.Toggle("Generate Mip Maps", generateMipMaps)) { inLinearSpace = EditorGUILayout.Toggle(" In Linear Space", inLinearSpace); borderMipMaps = EditorGUILayout.Toggle(" Border Mip Maps", borderMipMaps); mipMapFiltering = (TextureImporterMipFilter)DrawPopup(" Mip Map Filtering", (int)mipMapFiltering, mipMapFilteringString); if (fadeoutMipMaps = EditorGUILayout.Toggle(" Fadeout Mip Maps", fadeoutMipMaps)) { GUILayout.BeginHorizontal(); GUILayout.Label(" Fade Range"); GUILayout.Space(43f); EditorGUILayout.MinMaxSlider(ref fadeoutMin, ref fadeoutMax, 0, 10); fadeoutMin = Mathf.RoundToInt(fadeoutMin); fadeoutMax = Mathf.RoundToInt(fadeoutMax); GUILayout.EndHorizontal(); } } GUILayout.Space(8f); wrapMode = (TextureWrapMode)DrawPopup("Wrap Mode", (int)wrapMode, wrapModeString); if ((filterMode = (FilterMode)DrawPopup("Filter Mode", (int)filterMode, filterModeString)) != FilterMode.Point) { anisoLevel = EditorGUILayout.IntSlider("Aniso Level", anisoLevel, 0, 9); } break; default: break; } GUILayout.Space(8f); }
public override void ApplyCopiedValues(string[] properties, object[] values) { for (int i = 0; i < properties.Length; i++) { string property = properties[i]; if (property == "anisoLevel") { anisoLevel = (int)values[i]; } if (property == "borderMipmap") { borderMipmap = (bool)values[i]; } if (property == "convertToNormalmap") { convertToNormalmap = (bool)values[i]; } if (property == "correctGamma") { generateMipsInLinearSpace = (bool)values[i]; } if (property == "fadeout") { fadeout = (bool)values[i]; } if (property == "filterMode") { filterMode = (FilterMode)values[i]; } ; if (property == "generateCubemap") { generateCubemap = (TextureImporterGenerateCubemap)values[i]; } if (property == "grayscaleToAlpha") { grayscaleToAlpha = (bool)values[i]; } if (property == "heightmapScale") { heightmapScale = (float)values[i]; } if (property == "isReadable") { isReadable = (bool)values[i]; } if (property == "lightmap") { lightmap = (bool)values[i]; } if (property == "maxTextureSize") { maxTextureSize = (int)values[i]; } if (property == "mipMapBias") { mipMapBias = (float)values[i]; } if (property == "mipmapEnabled") { mipmapEnabled = (bool)values[i]; } if (property == "mipmapFadeDistanceEnd") { mipmapFadeDistanceEnd = (int)values[i]; } if (property == "mipmapFadeDistanceStart") { mipmapFadeDistanceStart = (int)values[i]; } if (property == "mipmapFilter") { mipmapFilter = (TextureImporterMipFilter)values[i]; } if (property == "normalmap") { normalmap = (bool)values[i]; } if (property == "normalmapFilter") { normalmapFilter = (TextureImporterNormalFilter)values[i]; } if (property == "npotScale") { npotScale = (TextureImporterNPOTScale)values[i]; } if (property == "textureFormat") { textureFormat = (TextureImporterFormat)values[i]; } if (property == "textureType") { textureType = (TextureImporterType)values[i]; } if (property == "wrapMode") { wrapMode = (TextureWrapMode)values[i]; } } }
public TextureAsset(StreamReader reader) { string line = string.Empty; while ((line = reader.ReadLine()) != null) { if (line.Contains(VerySimpleXml.EndNode(nodeName))) { break; } //Name if (line.Contains(VerySimpleXml.StartNode(nameNodeName))) { name = VerySimpleXml.NodeValue(line, nameNodeName); } //Path if (line.Contains(VerySimpleXml.StartNode(pathNodeName))) { guid = AssetDatabase.AssetPathToGUID(VerySimpleXml.NodeValue(line, pathNodeName)); } if (line.Contains(VerySimpleXml.StartNode(guidNodeName))) { guid = VerySimpleXml.NodeValue(line, guidNodeName); } //IMPORT SETTINGS if (line.Contains(VerySimpleXml.StartNode("anisoLevel"))) { anisoLevel = int.Parse(VerySimpleXml.NodeValue(line, "anisoLevel")); } if (line.Contains(VerySimpleXml.StartNode("borderMipmap"))) { borderMipmap = bool.Parse(VerySimpleXml.NodeValue(line, "borderMipmap")); } if (line.Contains(VerySimpleXml.StartNode("convertToNormalmap"))) { convertToNormalmap = bool.Parse(VerySimpleXml.NodeValue(line, "convertToNormalmap")); } if (line.Contains(VerySimpleXml.StartNode("correctGamma"))) { generateMipsInLinearSpace = bool.Parse(VerySimpleXml.NodeValue(line, "correctGamma")); } if (line.Contains(VerySimpleXml.StartNode("fadeout"))) { fadeout = bool.Parse(VerySimpleXml.NodeValue(line, "fadeout")); } if (line.Contains(VerySimpleXml.StartNode("filterMode"))) { filterMode = (FilterMode)System.Enum.Parse(typeof(FilterMode), VerySimpleXml.NodeValue(line, "filterMode")); } if (line.Contains(VerySimpleXml.StartNode("generateCubemap"))) { generateCubemap = (TextureImporterGenerateCubemap)System.Enum.Parse(typeof(TextureImporterGenerateCubemap), VerySimpleXml.NodeValue(line, "generateCubemap")); } if (line.Contains(VerySimpleXml.StartNode("grayscaleToAlpha"))) { grayscaleToAlpha = bool.Parse(VerySimpleXml.NodeValue(line, "grayscaleToAlpha")); } if (line.Contains(VerySimpleXml.StartNode("heightmapScale"))) { heightmapScale = float.Parse(VerySimpleXml.NodeValue(line, "heightmapScale")); } if (line.Contains(VerySimpleXml.StartNode("isReadable"))) { isReadable = bool.Parse(VerySimpleXml.NodeValue(line, "isReadable")); } if (line.Contains(VerySimpleXml.StartNode("lightmap"))) { lightmap = bool.Parse(VerySimpleXml.NodeValue(line, "lightmap")); } if (line.Contains(VerySimpleXml.StartNode("maxTextureSize"))) { maxTextureSize = int.Parse(VerySimpleXml.NodeValue(line, "maxTextureSize")); } if (line.Contains(VerySimpleXml.StartNode("mipMapBias"))) { mipMapBias = float.Parse(VerySimpleXml.NodeValue(line, "mipMapBias")); } if (line.Contains(VerySimpleXml.StartNode("mipmapEnabled"))) { mipmapEnabled = bool.Parse(VerySimpleXml.NodeValue(line, "mipmapEnabled")); } if (line.Contains(VerySimpleXml.StartNode("mipmapFadeDistanceEnd"))) { mipmapFadeDistanceEnd = int.Parse(VerySimpleXml.NodeValue(line, "mipmapFadeDistanceEnd")); } if (line.Contains(VerySimpleXml.StartNode("mipmapFadeDistanceStart"))) { mipmapFadeDistanceStart = int.Parse(VerySimpleXml.NodeValue(line, "mipmapFadeDistanceStart")); } if (line.Contains(VerySimpleXml.StartNode("mipmapFilter"))) { mipmapFilter = (TextureImporterMipFilter)System.Enum.Parse(typeof(TextureImporterMipFilter), VerySimpleXml.NodeValue(line, "mipmapFilter")); } if (line.Contains(VerySimpleXml.StartNode("normalmap"))) { normalmap = bool.Parse(VerySimpleXml.NodeValue(line, "normalmap")); } if (line.Contains(VerySimpleXml.StartNode("normalmapFilter"))) { normalmapFilter = (TextureImporterNormalFilter)System.Enum.Parse(typeof(TextureImporterNormalFilter), VerySimpleXml.NodeValue(line, "normalmapFilter")); } if (line.Contains(VerySimpleXml.StartNode("npotScale"))) { npotScale = (TextureImporterNPOTScale)System.Enum.Parse(typeof(TextureImporterNPOTScale), VerySimpleXml.NodeValue(line, "npotScale")); } if (line.Contains(VerySimpleXml.StartNode("textureFormat"))) { textureFormat = (TextureImporterFormat)System.Enum.Parse(typeof(TextureImporterFormat), VerySimpleXml.NodeValue(line, "textureFormat")); } if (line.Contains(VerySimpleXml.StartNode("textureType"))) { textureType = (TextureImporterType)System.Enum.Parse(typeof(TextureImporterType), VerySimpleXml.NodeValue(line, "textureType")); } if (line.Contains(VerySimpleXml.StartNode("wrapMode"))) { wrapMode = (TextureWrapMode)System.Enum.Parse(typeof(TextureWrapMode), VerySimpleXml.NodeValue(line, "wrapMode")); } } }
public TextureImportSettings() { textureFormat = TextureImporterFormat.AutomaticTruecolor; maxTextureSize = (int)TextureSize.Unlimited; grayscaleToAlpha = false; generateCubemap = TextureImporterGenerateCubemap.None; isReadable = false; mipmapEnabled = true; borderMipmap = false; mipmapFilter = TextureImporterMipFilter.BoxFilter; fadeout = false; mipmapFadeDistanceStart = 1; mipmapFadeDistanceEnd = 1; generateMipsInLinearSpace = false; normalmapFilter = TextureImporterNormalFilter.Standard; heightmapScale = 0.25f; anisoLevel = 1; filterMode = FilterMode.Bilinear; wrapMode = TextureWrapMode.Repeat; textureType = TextureImporterType.Image; }