Exemplo n.º 1
0
        public ImporterRule()
        {
            name = ImporterRulesWindow.GetNewRuleName();

            InitSettings();

            activeSettings = textureSettings;
        }
 private static void TryApplyRule(string assetPath, AssetImporter assetImporter, ImporterRulesTypes type)
 {
     if (waitPaths.Contains(assetPath))
     {
         waitPaths.Remove(assetPath);
     }
     else if (ImporterRulesWindow.ApplyFirstRule(type, assetPath, assetImporter))
     {
         waitPaths.Add(assetPath);
         AssetDatabase.ImportAsset(assetPath, ImportAssetOptions.ForceUpdate);
     }
 }
    private void OnGUI()
    {
        if (tempRule == null)
        {
            return;
        }

        tempRule.DrawEditor();

        GUILayout.BeginHorizontal();

        if (GUILayout.Button("Save"))
        {
            if (tempRule.pathComparer == ImporterRulesPathComparer.regex && !string.IsNullOrEmpty(tempRule.pattern))
            {
                try
                {
                    new Regex(tempRule.pattern);
                }
                catch (Exception)
                {
                    Debug.LogWarning("Regex pattern contains an error.");
                    return;
                }
            }

            if (activeRule != null)
            {
                activeRule.CopyFrom(tempRule);
            }
            else
            {
                ImporterRulesWindow.AddRule(tempRule);
            }
            ImporterRulesWindow.Save();
            ImporterRulesWindow.RedrawWindow();
            Close();
        }

        if (GUILayout.Button("Cancel"))
        {
            activeRule = null;
            Close();
        }

        GUILayout.EndHorizontal();
    }
Exemplo n.º 4
0
        public void DrawPreview(int index)
        {
            string[] types = { "TextureImporter", "ModelImporter", "AudioImporter", "MovieImporter", "TrueTypeFontImporter" };

            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUILayout.BeginHorizontal();
            expanded = GUILayout.Toggle(expanded, "", EditorStyles.foldout, GUILayout.ExpandWidth(false));

            EditorGUI.BeginChangeCheck();
            enabled = GUILayout.Toggle(enabled, "", GUILayout.ExpandWidth(false));
            if (EditorGUI.EndChangeCheck())
            {
                ImporterRulesWindow.Save();
            }

            GUILayout.Label(name + " [" + types[(int)type] + "]");

            if (ImporterRulesWindow.countRules > 1)
            {
                if (GUILayout.Button(new GUIContent("▲", "Move up"), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
                {
                    ImporterRulesWindow.SetRuleIndex(this, index - 1);
                }
                if (GUILayout.Button(new GUIContent("▼", "Move down"), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
                {
                    ImporterRulesWindow.SetRuleIndex(this, index + 1);
                }
            }
            if (GUILayout.Button(new GUIContent("►", "Apply the rule to the existing assets"), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
            {
                ImporterRulesWindow.onlyLogRules = Event.current.shift;
                if (EditorUtility.DisplayDialog("Apply the rule", "Apply the rule to the existing assets?", "Apply", "Cancel"))
                {
                    ApplyToExists();
                }
                ImporterRulesWindow.onlyLogRules = false;
            }
            if (GUILayout.Button(new GUIContent("E", "Edit"), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
            {
                ImporterRulesEditorWindow.OpenWindow(this);
            }
            if (GUILayout.Button(new GUIContent("D", "Duplicate"), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
            {
                ImporterRulesWindow.DuplicateRule(this);
            }
            if (GUILayout.Button(new GUIContent("X", "Delete"), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
            {
                if (EditorUtility.DisplayDialog("Delete rule", "You sure want to delete a rule?", "Delete", "Cancel"))
                {
                    deleted = true;
                }
            }
            EditorGUILayout.EndHorizontal();

            if (expanded)
            {
                EditorGUILayout.Space();
                EditorGUI.BeginDisabledGroup(true);

                DrawEditor(false);

                EditorGUI.EndDisabledGroup();
            }

            EditorGUILayout.EndVertical();
        }
 private void OnPreprocessTexture()
 {
     ImporterRulesWindow.ApplyFirstRule(ImporterRulesTypes.texture, assetPath, assetImporter);
 }
 private void OnPreprocessModel()
 {
     ImporterRulesWindow.ApplyFirstRule(ImporterRulesTypes.model, assetPath, assetImporter);
 }
 private void OnPreprocessAudio()
 {
     ImporterRulesWindow.ApplyFirstRule(ImporterRulesTypes.audio, assetPath, assetImporter);
 }
 public static void OpenWindow()
 {
     wnd = GetWindow <ImporterRulesWindow>(false, "Importer Rules", true);
 }
 private void OnEnable()
 {
     wnd = this;
     Load(null, true);
 }