Skip to content

Unity import: materials on placed models, and a Flat colour row - #238

Merged
rixnobis merged 4 commits into
mainfrom
unity-placed-material
Oct 21, 2026
Merged

rixnobis merged 4 commits into
mainfrom
unity-placed-material

Conversation

@rixnobis

Copy link
Copy Markdown
Contributor

Part of #223. A placed model came in with no texture when its material was set in the scene (a m_Materials.Array.data[0] override on the model's MeshRenderer, which meshOf ignored for models) or remapped in the .fbx.meta (externalObjects, which nothing read). Both now apply.

The exporter's flat colour was imported correctly. The inspector had no field for it, so a Flat colour row now shows under Lighting when Lighting is Flat (obj.flatcolor, undoable).

Tests: testUnityPlacedMaterial on a fixture scene saved by Unity 6000.3 (both cases), and tests/flatcolourcheck.py. skininfocheck and cliploopcheck now scroll to their target, since the new row moves them.

A model placed in a scene keeps its MeshRenderer inside the model, so
a material dragged onto it is stored as an m_Materials.Array.data[N]
modification on the PrefabInstance. meshOf read that override but then
took the model's own material anyway whenever the object had no scene
MeshRenderer, so the instance came in untextured.

An override now beats the model's material. The unity-models fixture
gains materials.unity (saved by Unity 6000.3) with such an instance.
A model's .meta can remap its materials to project materials (the
Materials tab's On Demand Remap, or Search and Remap): externalObjects
entries of type UnityEngine:Material, keyed by the material's name in
the model file. The import never read them, so a model drawn in Unity
with a textured project material came in with its own material.

Imported models now keep each submesh's material name, and the Unity
import swaps in the remapped .mat where the .meta names one.
With Lighting set to Flat every vertex of the mesh gets one colour, but
the inspector showed no trace of it: an imported Unity Flat Color came
in, yet could be neither seen nor changed. The row shows only in Flat
mode, with the same colour well and picker as a material's Colour row;
a pick is an undo step, a drag one step. The Lighting row is named
obj.lighting, and scripted runs print "flatcolor: R,G,B".

flatcolourcheck drives it on the Unity materials fixture. cliploopcheck
now scrolls to the Agent section's last control rather than a fixed
wheel, as its Flat mesh makes the inspector one row taller.
The Flat colour row makes a Flat skinned mesh's inspector one row
taller, which pushes the Long clip card below the panel at 1600x960.
Scroll to the card before checking that it lies inside the panel.
@rixnobis
rixnobis merged commit 1c82927 into main Oct 21, 2026
5 checks passed
@rixnobis
rixnobis deleted the unity-placed-material branch October 21, 2026 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant