Ejemplo n.º 1
0
    protected void DrawPlatformSettings()
    {
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(10);

        //GUI.changed = false;
        Rect rect = EditorGUILayout.BeginVertical(GUI.skin.box, new GUILayoutOption[0]);

        rect.width -= 1f;
        int      height        = 18;
        GUIStyle toolbarButton = EditorStyles.toolbarButton;

        int platformIndex = 0;
        int platformCount = m_FormatData.TargetImporterData.PlatformOverrideContences.Count;

        foreach (var item in m_FormatData.TargetImporterData.PlatformOverrideContences)
        {
            Rect position;
            int  startX = Mathf.RoundToInt((float)platformIndex * rect.width / (float)platformCount);
            int  endX   = Mathf.RoundToInt((float)(platformIndex + 1) * rect.width / (float)platformCount);
            position = new Rect(rect.x + (float)startX, rect.y, (float)(endX - startX), (float)height);
            if (GUI.Toggle(position, CurrentSelectPlatform == item.Key, item.Value.OverrideContent, toolbarButton))
            {
                CurrentSelectPlatform = item.Key;
            }
            platformIndex++;
        }

        GUILayoutUtility.GetRect(10f, (float)height);
        PlatformOverrideContence current = m_FormatData.TargetImporterData.PlatformOverrideContences[CurrentSelectPlatform];
        string label      = "Override for " + current.TargetPlatform;
        bool   isOverride = EditorGUILayout.ToggleLeft(label, current.IsOverride, new GUILayoutOption[0]);

        if (isOverride != current.IsOverride)
        {
            current.IsOverride = isOverride;
        }

        EditorGUILayout.HelpBox("如果当前MaxSize为倍率压缩时,NormalMap不受影响(不改变)", MessageType.Info);
        current.MaxSize       = EditorGUILayout.IntPopup("Max Size", current.MaxSize, MAXTEXTURESIZESTRINGS, TextureFormatData.MAXTEXTURESIZEVALUES, new GUILayoutOption[0]);
        current.DefaultFormat = (TextureImporterFormat)EditorGUILayout.EnumPopup("Default Format", current.DefaultFormat, new GUILayoutOption[0]);
        current.NormalFormat  = (TextureImporterFormat)EditorGUILayout.EnumPopup("Normal Format", current.NormalFormat, new GUILayoutOption[0]);
        EditorGUILayout.EndVertical();

        GUILayout.Space(10);
        EditorGUILayout.EndHorizontal();
    }
Ejemplo n.º 2
0
    protected void PlatformTextureSetting(TextureImporter textureImporter, string platfrom, PlatformOverrideContence targetPlatformFomat, bool isUsingUnityDefaultCompress)
    {
        //if (m_PlatformOverrideContence == null || !m_PlatformOverrideContence.ContainsKey(platfrom))
        //{
        //	return;
        //}

        //OverrideContence targetPlatformFomat = m_PlatformOverrideContence[platfrom];
        TextureImporterPlatformSettings sourcePlatformImporterSettings = textureImporter.GetPlatformTextureSettings(platfrom);

        sourcePlatformImporterSettings.overridden = targetPlatformFomat.IsOverride;

        if (targetPlatformFomat.MaxSize <= 3 && targetPlatformFomat.MaxSize != -1)
        {
            sourcePlatformImporterSettings.maxTextureSize = GetLowLevelSize(textureImporter.maxTextureSize, targetPlatformFomat.MaxSize);
        }
        else if (targetPlatformFomat.MaxSize != -1)
        {
            sourcePlatformImporterSettings.maxTextureSize = targetPlatformFomat.MaxSize;
        }

        //if(isUsingUnityDefaultCompress)
        //{
        //	textureImporter.SetPlatformTextureSettings(sourcePlatformImporterSettings);
        //	return;
        //}

        if (textureImporter.textureType == TextureImporterType.Default)
        {
            // 优化策略,只修改不是ETC或者PVRTC压缩格式的图为指定的压缩格式 [11:49  27/4/2018  BingLau]
            if (CheckNeedChangeFormat(sourcePlatformImporterSettings.format))
            {
                sourcePlatformImporterSettings.format = targetPlatformFomat.DefaultFormat;
            }
            textureImporter.SetPlatformTextureSettings(sourcePlatformImporterSettings);
        }
        else if (textureImporter.textureType == TextureImporterType.NormalMap)
        {
            if (CheckNeedChangeFormat(sourcePlatformImporterSettings.format))
            {
                sourcePlatformImporterSettings.format = targetPlatformFomat.NormalFormat;
            }
            textureImporter.SetPlatformTextureSettings(sourcePlatformImporterSettings);
        }
    }