Unity3D: Extract Textures from FBX via C# script

1.6k Views Asked by At

I am struggling to find a way to extract textures from an FBX model in Unity via script. Unity has a hidden method to extract materials here, but cannot find a method to extract textures even in their own github.

i even tried to use the same approach to load Texture2D-s from the asset file like so:

    IEnumerable<Object> enumerable = from x in AssetDatabase.LoadAllAssetsAtPath(assetPath)
                                                 where x.GetType() == typeof(Texture2D)
                                                 select x;

but to no avail. Can anyone help? thank you!

1

There are 1 best solutions below

0
On

You can achieve this using ModelImporter:

var tex = AssetImporter.GetAtPath(pathToFbx) as ModelImporter;
tex.ExtractTextures(destinationPath);