Skip to content

Commit a09bb2a

Browse files
authored
Merge pull request #114 from dsarno/codex/fix-color-conflict-detection-logic
2 parents e4dc7c6 + 20c1fff commit a09bb2a

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

MCPForUnity/Editor/Tools/ManageMaterial.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,26 @@ private static object CreateMaterial(JObject @params)
510510

511511
// Apply color param during creation (keeps Python tool signature and C# implementation consistent).
512512
// If "properties" already contains a color property, let properties win.
513-
if (colorToken != null && (properties == null || (!properties.ContainsKey("_BaseColor") && !properties.ContainsKey("_Color")
514-
&& (string.IsNullOrEmpty(colorProperty) || !properties.ContainsKey(colorProperty)))))
513+
bool shouldApplyColor = false;
514+
if (colorToken != null)
515+
{
516+
if (properties == null)
517+
{
518+
shouldApplyColor = true;
519+
}
520+
else if (!string.IsNullOrEmpty(colorProperty))
521+
{
522+
// If colorProperty is specified, only check that specific property.
523+
shouldApplyColor = !properties.ContainsKey(colorProperty);
524+
}
525+
else
526+
{
527+
// If colorProperty is not specified, check fallback properties.
528+
shouldApplyColor = !properties.ContainsKey("_BaseColor") && !properties.ContainsKey("_Color");
529+
}
530+
}
531+
532+
if (shouldApplyColor)
515533
{
516534
Color color;
517535
try

0 commit comments

Comments
 (0)