Esempio n. 1
0
 private void LoadFormatRuleList()
 {
     this.formatRuleList = new List <TextureImportFormatChangeRule>();
     if (File.Exists(this.FormatRuleFilePath))
     {
         String[] lines = File.ReadAllLines(this.FormatRuleFilePath);
         if (lines != null)
         {
             foreach (var line in lines)
             {
                 string[] p = line.Split('\t');
                 if (p.Length < 3)
                 {
                     continue;
                 }
                 var rule = new TextureImportFormatChangeRule(p[0], (TextureImporterFormat)(Int32.Parse(p[1])), Int32.Parse(p[2]));
                 this.formatRuleList.Add(rule);
             }
         }
     }
     if (formatRuleList.Count == 0)
     {
         this.formatRuleList.Add(new TextureImportFormatChangeRule("**", TextureImporterFormat.AutomaticCompressed, 80));
     }
 }
Esempio n. 2
0
        private ERuleButtonAction OnGUIFormatRule(TextureImportFormatChangeRule formatRule, bool isTop, bool isBottom)
        {
            ERuleButtonAction action = ERuleButtonAction.Nothing;

            EditorGUILayout.BeginHorizontal();
            if (isTop)
            {
                GUILayout.Label("", GUILayout.Width(20));
            }
            else
            {
                if (GUILayout.Button(LanguageData.GetString(ETags.UpperBtn), GUILayout.Width(20)))
                {
                    action = ERuleButtonAction.Upper;
                }
            }
            if (isBottom)
            {
                GUILayout.Label("", GUILayout.Width(20));
            }
            else
            {
                if (GUILayout.Button(LanguageData.GetString(ETags.DownerBtn), GUILayout.Width(20)))
                {
                    action = ERuleButtonAction.Downer;
                }
            }

            formatRule.pathMatch = EditorGUILayout.TextField(formatRule.pathMatch);

            int selectFormatIdx = GetPopFormatRuleUpIndex(this.AllowFormatList, formatRule.textureFormat);

            selectFormatIdx          = EditorGUILayout.Popup(selectFormatIdx, this.AllowFormatStringList, GUILayout.Width(120.0f));
            formatRule.textureFormat = this.AllowFormatList[selectFormatIdx];

            if (IsNeedQualityFormat(formatRule.textureFormat))
            {
                formatRule.quality = EditorGUILayout.IntField(formatRule.quality, GUILayout.Width(40));
                formatRule.quality = Mathf.Clamp(formatRule.quality, 0, 100);
            }
            else
            {
                EditorGUILayout.LabelField("", GUILayout.Width(40));
            }

            if (GUILayout.Button(LanguageData.GetString(ETags.DeleteBtn), GUILayout.Width(50.0f)))
            {
                action = ERuleButtonAction.Delete;
            }
            EditorGUILayout.EndHorizontal();
            return(action);
        }
Esempio n. 3
0
        private void SwapFormatRule(List <TextureImportFormatChangeRule> rules, int idx1, int idx2)
        {
            if (rules == null ||
                idx1 < 0 || idx2 < 0 ||
                idx1 >= rules.Count || idx2 >= rules.Count)
            {
                return;
            }
            TextureImportFormatChangeRule tmp = rules[idx1];

            rules[idx1] = rules[idx2];
            rules[idx2] = tmp;
        }