Esempio n. 1
0
    private static void FormatModel()
    {
        List <ModelImporter> modelImporters = new List <ModelImporter>();
        var objs = Selection.objects;

        foreach (var o in objs)
        {
            string path = AssetDatabase.GetAssetPath(o);
            modelImporters.AddRange(GetImporterByPath <ModelImporter>(path));
        }
        List <TextureImporter> textureImporters = new List <TextureImporter>();

        foreach (var o in objs)
        {
            string path = AssetDatabase.GetAssetPath(o);
            textureImporters.AddRange(GetImporterByPath <TextureImporter>(path));
        }
        int   totalCount = modelImporters.Count + textureImporters.Count;
        float index      = 0;

        foreach (var modelImporter in modelImporters)
        {
            index++;
            EditorUtility.DisplayProgressBar("正在格式化资源", modelImporter.assetPath, index / totalCount);
            ModelProcessor.FormatModel(modelImporter);
        }

        foreach (var importer in textureImporters)
        {
            index++;
            EditorUtility.DisplayProgressBar("正在格式化资源", importer.assetPath, index / totalCount);
            TextureProcessor.FormatTexture(importer);
        }

        EditorUtility.ClearProgressBar();
    }