GetPlatformTextureSettings() public method

Get platform specific texture settings.

public GetPlatformTextureSettings ( string platform ) : TextureImporterPlatformSettings
platform string The platform whose settings are required (see below).
return TextureImporterPlatformSettings
        public void AnalyzerTexture()
        {
            this.width = this.texture.width;
            this.height = this.texture.height;
            this.size = CalculateTextureSizeBytes(this.texture);
            this.ti = AssetImporter.GetAtPath(path) as TextureImporter;
            if (ti != null)
            {
                this.isRW = ti.isReadable;

                androidPlatSetting.isSetting = ti.GetPlatformTextureSettings(TexturePlatSetting.PLAT_ANDROID,
                        out androidPlatSetting.maxSize, out androidPlatSetting.textureFormat);

                iosPlatSetting.isSetting = ti.GetPlatformTextureSettings(TexturePlatSetting.PLAT_IPHONE,
                        out iosPlatSetting.maxSize, out iosPlatSetting.textureFormat);

                standalonePlatSetting.isSetting = ti.GetPlatformTextureSettings(TexturePlatSetting.PLAT_STANDALONE,
                        out standalonePlatSetting.maxSize, out standalonePlatSetting.textureFormat);

                this.isMipmap = ti.mipmapEnabled;
                this.isLightmap = ti.lightmap;
                this.anisoLevel = ti.anisoLevel;
            }

            CheckValid();
        }
示例#2
0
    /// <summary>
    /// 设置图片 样式
    /// </summary>
    /// <param name="iOSFroamt"></param>
    /// <param name="AndroidFroamt"></param>
    static void SettingTexture(TextureImporterFormat iOSFroamt, TextureImporterFormat?AndroidFroamt = null)
    {
        if (null == AndroidFroamt)
        {
            AndroidFroamt = iOSFroamt;
        }
        List <string> fileList = new List <string>();

        /// 遍历 目录 操作
        if (null != Selection.objects)
        {
            for (int index = 0; index < Selection.objects.Length; index++)
            {
                if (null != Selection.objects[index])
                {
                    string path = string.Format("{0}/../{1}", Application.dataPath, AssetDatabase.GetAssetPath(Selection.objects[index]));
                    if (System.IO.Directory.Exists(path))
                    {
                        EditorSearchFile.SearchPath(path, fileList, "");
                    }
                    else
                    {
                        fileList.Add(path);
                    }
                }
            }
        }
        for (int index = 0; index < fileList.Count; index++)
        {
            string path = fileList[index];
            while (path.LastIndexOf("Assets/", System.StringComparison.Ordinal) != 0 && path.LastIndexOf("Assets/", System.StringComparison.Ordinal) != -1)
            {
                path = path.Substring(path.LastIndexOf("Assets/", System.StringComparison.Ordinal));
            }
            UnityEditor.TextureImporter importer = UnityEditor.TextureImporter.GetAtPath(path) as UnityEditor.TextureImporter;
            if (null == importer)
            {
                continue;
            }
            importer.mipmapEnabled = false;
            /// 读取
            TextureImporterPlatformSettings iOS     = importer.GetPlatformTextureSettings("iPhone");
            TextureImporterPlatformSettings Android = importer.GetPlatformTextureSettings("Android");
            /// 重写 设成 true
            Android.overridden           = iOS.overridden = true;
            importer.textureType         = TextureImporterType.Sprite;
            importer.alphaSource         = TextureImporterAlphaSource.FromInput;
            importer.alphaIsTransparency = true;
            importer.npotScale           = TextureImporterNPOTScale.None;
            /// 类型设置
            Android.format = (TextureImporterFormat)AndroidFroamt;
            iOS.format     = iOSFroamt;
            /// 赋值
            importer.SetPlatformTextureSettings(iOS);
            importer.SetPlatformTextureSettings(Android);
            /// LOG
            Debug.Log(string.Format("Setting Texture : [ Android = {1}, iOS = {2} ]{0}", path, AndroidFroamt, iOSFroamt));
            /// 保存
            importer.SaveAndReimport();
        }
    }
 protected bool HasPlatformEnabledAlphaSplittingForCompression(string targetName, TextureImporter ti)
 {
     TextureImporterPlatformSettings platformTextureSettings = ti.GetPlatformTextureSettings(targetName);
     return (platformTextureSettings.overridden && platformTextureSettings.allowsAlphaSplitting);
 }
 private bool GetOverridden(TextureImporter importer)
 {
   if (!this.m_OverriddenIsDifferent)
     return this.m_Overridden;
   int maxTextureSize;
   TextureImporterFormat textureFormat;
   return importer.GetPlatformTextureSettings(this.name, out maxTextureSize, out textureFormat);
 }
			private bool GetOverridden(TextureImporter importer)
			{
				if (!this.m_OverriddenIsDifferent)
				{
					return this.m_Overridden;
				}
				int num;
				TextureImporterFormat textureImporterFormat;
				return importer.GetPlatformTextureSettings(this.name, out num, out textureImporterFormat);
			}