示例#1
0
    static void TextureProcess(TextureAction func)
    {
        Object[] textures = Selection.GetFiltered(typeof(Texture2D), SelectionMode.DeepAssets);

        int n = textures.Length;

        AssetDatabase.StartAssetEditing();

        Selection.objects = new Object[0];
        for (int i = 0; i < n; i++)
        {
            Texture2D texture = textures[i] as Texture2D;

            string path = AssetDatabase.GetAssetPath(texture);

            if (EditorUtility.DisplayCancelableProgressBar(string.Format("{0}", path), i + "/" + textures.Length, (float)i / (float)textures.Length))
            {
                break;
            }

            // Debug.LogFormat("reimport {0}/{1}: {2}", i+1, n, path);
            TextureImporter textureImporter = AssetImporter.GetAtPath(path) as TextureImporter;
            if (func(textureImporter))
            {
                AssetDatabase.ImportAsset(path);
            }
            // textureImporter.SaveAndReimport();
        }

        AssetDatabase.StopAssetEditing();
        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();
        EditorUtility.ClearProgressBar();
    }
示例#2
0
 internal TimeSpan Estimate(TextureAction action) => Estimate(action.Size);
示例#3
0
 internal void Add(TextureAction action, TimeSpan duration) => Add(action.Size, duration);
 internal TextureActionTask(Action action, TextureAction actionData) : base(action)
 {
     ActionData = actionData;
 }
示例#5
0
 public void SetCallback(TextureAction a)
 {
     callback = a;
 }