public override void Save(XmlElement element)
 {
     element.CreateChild("TextureType", textureType.ToString());
     element.CreateChild("UseOriginalSize", useOriginalSize);
     PropertyInfo[] props = typeof(TextureImporterSettings).GetProperties();
     SaveSerialized(element, settings, props);
 }
Пример #2
0
        // Token: 0x060003DC RID: 988 RVA: 0x00034930 File Offset: 0x00032B30
        public static string GetTextureTypeString(TextureImporterType type, TextureImporterShape shape)
        {
            if ((int)shape == 2)
            {
                return("Cubemap");
            }
            switch ((int)type)
            {
            case 0:
                return("Default");

            case 1:
                return("Normal map");

            case 2:
                return("Editor GUI & Legacy UI");

            case 4:
                return("Cookie");

            case 6:
                return("Lightmap");

            case 7:
                return("Cursor");

            case 8:
                return("Sprite (2D & UI)");

            case 10:
                return("Single Channel");
            }
            return(type.ToString());
        }
Пример #3
0
        // ========================================================================================

        static string TextureTypeToReadableString(TextureImporterType textureType)
        {
            switch (textureType)
            {
            case TextureImporterType.Default:
                return("Default");

            case TextureImporterType.NormalMap:
                return("Normal Map");

            case TextureImporterType.GUI:
                return("GUI");

            case TextureImporterType.Sprite:
                return("Sprite");

            case TextureImporterType.Cursor:
                return("Cursor");

            case TextureImporterType.Cookie:
                return("Cookie");

            case TextureImporterType.Lightmap:
                return("Lightmap");

#if UNITY_2020_2_OR_NEWER
            case TextureImporterType.DirectionalLightmap:
                return("Directional Lightmap");
#endif
            case TextureImporterType.SingleChannel:
                return("Single Channel");

            default:
                return(textureType.ToString());
            }
        }
Пример #4
0
    private void OnGUI()
    {
        GUILayout.BeginVertical();
        GUILayout.Space(10f);
        GUILayout.BeginHorizontal();
        GUILayout.Space(10f);
        textureType = (TextureImporterType)DrawPopup("Texture Type", (int)textureType, textureTypeString, textureTypeArray);
        GUILayout.Space(10f);
        GUILayout.EndHorizontal();

        if (DrawHeader(textureType.ToString()))
        {
            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(11f);
            EditorGUILayout.BeginVertical("As TextArea", GUILayout.MinHeight(18));
            GUILayout.Space(2f);
            DrawTextureSettings(textureType);
            GUILayout.Space(2f);
            EditorGUILayout.EndVertical();
            GUILayout.Space(15f);
            EditorGUILayout.EndHorizontal();
            GUILayout.Space(5f);
        }
        oldTextureType = textureType;

        platformIndex = DrawPlatformHeader(platformImages, platformIndex);
        GUILayout.Space(-4f);
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(11f);
        EditorGUILayout.BeginVertical("As TextArea", GUILayout.MinHeight(18));
        GUILayout.Space(2f);
        DrawPlatformSettings(platformStrings, textureType, platformIndex);
        GUILayout.Space(2f);
        EditorGUILayout.EndVertical();
        GUILayout.Space(15f);
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(5f);
        if (GUI.changed)
        {
            changed = true;
        }

        GUILayout.BeginHorizontal();
        GUILayout.Space(10f);
        if (GUILayout.Button("Select all"))
        {
            SelectAll();
        }

        GUI.enabled = changed;
        if (GUILayout.Button("Revert"))
        {
            Revert();
            changed = false;
        }

        GUI.enabled = true;
        if (GUILayout.Button("Apply all"))
        {
            ApplyAll();
        }
        GUILayout.Space(10f);
        GUILayout.EndHorizontal();
        GUILayout.EndVertical();
    }
    public override void DrawImportSettings()
    {
        string          path            = AssetDatabase.GUIDToAssetPath(guid);
        TextureImporter textureImporter = AssetImporter.GetAtPath(path) as TextureImporter;

        //If importer is still null, asset can't be found at path
        if (textureImporter == null)
        {
            GUILayout.Label("Texture Asset with GUID: " + guid + " no longer exists.");
        }
        else
        {
            //Name
            GUILayout.Label("Name: " + name);
            //Path
            GUILayout.Label("Path: " + path);
            //GUID
            GUILayout.Label("GUID: " + guid);

            //Aniso level
            GUILayout.Label("Aniso level: " + anisoLevel.ToString(), textureImporter.anisoLevel != anisoLevel ? AssetSettingsWindow.singleton.redTextStyle : EditorStyles.label);
            //Border mipmap
            GUILayout.Label("Border mipmap: " + borderMipmap.ToString(), textureImporter.borderMipmap != borderMipmap ? AssetSettingsWindow.singleton.redTextStyle : EditorStyles.label);
            //Convert to normal map
            GUILayout.Label("Conver to normal map: " + convertToNormalmap.ToString(), textureImporter.convertToNormalmap != convertToNormalmap ? AssetSettingsWindow.singleton.redTextStyle : EditorStyles.label);
            //Correct gamma
            GUILayout.Label("Correct gamma: " + generateMipsInLinearSpace.ToString(), textureImporter.generateMipsInLinearSpace != generateMipsInLinearSpace ? AssetSettingsWindow.singleton.redTextStyle : EditorStyles.label);
            //Fadeout
            GUILayout.Label("Fadeout: " + fadeout.ToString(), textureImporter.fadeout != fadeout ? AssetSettingsWindow.singleton.redTextStyle : EditorStyles.label);
            //Filter mode
            GUILayout.Label("Filter mode: " + filterMode.ToString(), textureImporter.filterMode != filterMode ? AssetSettingsWindow.singleton.redTextStyle : EditorStyles.label);
            //Generate cubemap
            GUILayout.Label("Generate cubemap: " + generateCubemap.ToString(), textureImporter.generateCubemap != generateCubemap ? AssetSettingsWindow.singleton.redTextStyle : EditorStyles.label);
            //Heightmap scale
            GUILayout.Label("Heightmap scale: " + heightmapScale.ToString(), textureImporter.heightmapScale != heightmapScale ? AssetSettingsWindow.singleton.redTextStyle : EditorStyles.label);
            //Is readable
            GUILayout.Label("Is readable: " + isReadable.ToString(), textureImporter.isReadable != isReadable ? AssetSettingsWindow.singleton.redTextStyle : EditorStyles.label);
            //Lightmap
            GUILayout.Label("Lightmap: " + lightmap.ToString(), textureImporter.lightmap != lightmap ? AssetSettingsWindow.singleton.redTextStyle : EditorStyles.label);
            //Max texture size
            GUILayout.Label("Max texture size: " + maxTextureSize.ToString(), textureImporter.maxTextureSize != maxTextureSize ? AssetSettingsWindow.singleton.redTextStyle : EditorStyles.label);
            //Mipmap bias
            GUILayout.Label("Mipmap bias: " + mipMapBias.ToString(), textureImporter.mipMapBias != mipMapBias ? AssetSettingsWindow.singleton.redTextStyle : EditorStyles.label);
            //Mipmap enabled
            GUILayout.Label("Mipmap enabled: " + mipmapEnabled.ToString(), textureImporter.mipmapEnabled != mipmapEnabled ? AssetSettingsWindow.singleton.redTextStyle : EditorStyles.label);
            //Mipmap fade distance start
            GUILayout.Label("Mipmap fade distance start: " + mipmapFadeDistanceStart.ToString(), textureImporter.mipmapFadeDistanceStart != mipmapFadeDistanceStart ? AssetSettingsWindow.singleton.redTextStyle : EditorStyles.label);
            //Mipmap fade distance end
            GUILayout.Label("Mipmap fade distance end: " + mipmapFadeDistanceEnd.ToString(), textureImporter.mipmapFadeDistanceEnd != mipmapFadeDistanceEnd ? AssetSettingsWindow.singleton.redTextStyle : EditorStyles.label);
            //Mipmap filter
            GUILayout.Label("Mipmap filter: " + mipmapFilter.ToString(), textureImporter.mipmapFilter != mipmapFilter ? AssetSettingsWindow.singleton.redTextStyle : EditorStyles.label);
            //Normalmap
            GUILayout.Label("Normalmap: " + normalmap.ToString(), textureImporter.normalmap != normalmap ? AssetSettingsWindow.singleton.redTextStyle : EditorStyles.label);
            //Normalmap filter
            GUILayout.Label("Normalmap filter: " + normalmapFilter.ToString(), textureImporter.normalmapFilter != normalmapFilter ? AssetSettingsWindow.singleton.redTextStyle : EditorStyles.label);
            //NPOT scale
            GUILayout.Label("NPOT scale: " + npotScale.ToString(), textureImporter.npotScale != npotScale ? AssetSettingsWindow.singleton.redTextStyle : EditorStyles.label);
            //Texture format
            GUILayout.Label("Texture format: " + textureFormat.ToString(), textureImporter.textureFormat != textureFormat ? AssetSettingsWindow.singleton.redTextStyle : EditorStyles.label);
            //Texture type
            GUILayout.Label("Texture type: " + textureType.ToString(), textureImporter.textureType != textureType ? AssetSettingsWindow.singleton.redTextStyle : EditorStyles.label);
            //Wrap mode
            GUILayout.Label("Wrap mode: " + wrapMode.ToString(), textureImporter.wrapMode != wrapMode ? AssetSettingsWindow.singleton.redTextStyle : EditorStyles.label);
        }
    }
        public override void DrawRuleGUI()
        {
            base.DrawRuleGUI();
            GUILayout.Space(10);

            EditorGUILayout.LabelField("Texture Rule Settings", EditorStyles.boldLabel);
            EditorGUI.DrawRect(EditorGUILayout.GetControlRect(false, 2), QuickEditorColors.DarkGrayX11);
            GUILayout.Space(3);

            int mTextureTypeIndex = Math.Max(Array.FindIndex(AssetImportStyles.Texture.TextureTypeOpts, opt => opt.text.Equals(textureType.ToString())), 0);

            mTextureTypeIndex = EditorGUILayout.Popup(AssetImportStyles.Texture.TextureType, mTextureTypeIndex, AssetImportStyles.Texture.TextureTypeOpts);
            textureType       = AssetImportStyles.Texture.TextureTypeEnumOpts[mTextureTypeIndex];

            bool disabled = (textureType == TextureImporterType.Default || textureType == TextureImporterType.NormalMap || textureType == TextureImporterType.SingleChannel) ? false : true;

            EditorGUI.BeginDisabledGroup(disabled);
            textureShape = (TextureImporterShape)EditorGUILayout.EnumPopup("Texture Shape", textureShape);
            EditorGUI.EndDisabledGroup();
            if (disabled)
            {
                textureShape = TextureImporterShape.Texture2D;
            }

            GUILayout.Space(5);

            advanceFoldout = EditorGUILayout.Foldout(advanceFoldout, AssetImportStyles.Texture.Advanced);

            if (advanceFoldout)
            {
                QuickGUILayout.IndentBlock(() =>
                {
                    npotScale     = (TextureImporterNPOTScale)EditorGUILayout.EnumPopup(AssetImportStyles.Texture.NonPowerof2, npotScale);
                    isReadable    = EditorGUILayout.Toggle(AssetImportStyles.Texture.ReadWriteEnable, isReadable);
                    mipmapEnabled = EditorGUILayout.Toggle(AssetImportStyles.Texture.GenMipMaps, mipmapEnabled);
                });
            }

            GUILayout.Space(5);

            wrapMode   = (TextureWrapMode)EditorGUILayout.EnumPopup(AssetImportStyles.Texture.WrapMode, wrapMode);
            filterMode = (FilterMode)EditorGUILayout.EnumPopup(AssetImportStyles.Texture.FilterMode, filterMode);
            anisoLevel = EditorGUILayout.IntSlider(AssetImportStyles.Texture.AnisoLevel, anisoLevel, 0, 16);

            GUILayout.Space(10);

            GUILayout.BeginHorizontal(EditorStyles.toolbar);

            QuickGUILayout.Toolbar(ref curPlatformIndex, mPlatformNames, EditorStyles.toolbarButton, GUILayout.ExpandWidth(true));
            GUILayout.Space(10);
            GUILayout.EndHorizontal();

            EditorGUILayout.BeginVertical("Box");

            if (curPlatformIndex == 0)
            {
                StandaloneTextureImporterSettings.overridden = EditorGUILayout.Toggle("Override for Standalone", StandaloneTextureImporterSettings.overridden);
            }
            else if (curPlatformIndex == 1)
            {
                AndroidTextureImporterSettings.overridden = EditorGUILayout.Toggle("Override for Android", AndroidTextureImporterSettings.overridden);
            }
            else if (curPlatformIndex == 2)
            {
                iOSTextureImporterSettings.overridden = EditorGUILayout.Toggle("Override for iOS", iOSTextureImporterSettings.overridden);
            }

            int num = Array.FindIndex(AssetImportStyles.Texture.MaxSizeOpts, content => content.text.Equals(maxTextureSize.ToString()));

            num            = Math.Max(num, 0);
            num            = EditorGUILayout.Popup(AssetImportStyles.Texture.MaxSize, num, AssetImportStyles.Texture.MaxSizeOpts);
            maxTextureSize = Convert.ToInt32(AssetImportStyles.Texture.MaxSizeOpts[num].text);

            if (curPlatformIndex == 0)
            {
                StandaloneTextureImporterSettings.resizeAlgorithm = (TextureResizeAlgorithm)EditorGUILayout.EnumPopup("Resize Algorithm", StandaloneTextureImporterSettings.resizeAlgorithm);
                StandaloneTextureImporterSettings.format          = (TextureImporterFormat)EditorGUILayout.EnumPopup("Format", StandaloneTextureImporterSettings.format);
            }
            else if (curPlatformIndex == 1)
            {
                AndroidTextureImporterSettings.resizeAlgorithm = (TextureResizeAlgorithm)EditorGUILayout.EnumPopup("Resize Algorithm", AndroidTextureImporterSettings.resizeAlgorithm);
                AndroidTextureImporterSettings.format          = (TextureImporterFormat)EditorGUILayout.EnumPopup("Format", AndroidTextureImporterSettings.format);
            }
            else if (curPlatformIndex == 2)
            {
                iOSTextureImporterSettings.resizeAlgorithm = (TextureResizeAlgorithm)EditorGUILayout.EnumPopup("Resize Algorithm", iOSTextureImporterSettings.resizeAlgorithm);
                iOSTextureImporterSettings.format          = (TextureImporterFormat)EditorGUILayout.EnumPopup("Format", iOSTextureImporterSettings.format);
            }

            EditorGUILayout.EndVertical();
        }