Trying to applying a texture dynamically during runtime to _BaseColorMap and exporting GameObject as FBX afterwards. Texture correctly applied to the shader and is also visible in Game View. But Texture is not assigned to _BaseColorMap in the exported FBX.
I manually applied a texture before runtime to _BaseColorMap in Unity Editor and exporting FBX which works as expected.
Not sure what’s the difference here or why it is not included in the FBX when i assign it during runtime.
Example Code
// Init chip GameObject based on Prefab
chip = Instantiate(chipPrefab, new Vector3(0, 0, 0), Quaternion.identity);
// Assign material to chip Mesh Renderer
ringOutsideRenderer = chip.transform.Find("ring_outside").GetComponent<MeshRenderer>();
ringOutsideRenderer.material = ringOutsideMaterial;
// Set texture on Mesh Renderer Material
ringOutsideRenderer.material.SetTexture("_BaseColorMap", ringTexture);
// Export chip as FBX
string filePath = Path.Combine(Application.dataPath, exportFileBasename + ".fbx");
Object[] objects = new Object[1];
objects[0] = chip;
ModelExporter.ExportObjects(filePath, objects);
Debug.Log("Export: " + exportFileBasename + ".fbx");
// Problem: FBX does not include textures applied
// Research: Applying a texture to _BaseColorMap in Unity Editor and exporting FBX, includes texture
