Skip to content

Commit

Permalink
fix: Loose string name check using 'Contains' potentially leading to …
Browse files Browse the repository at this point in the history
…false-positive mat returns
  • Loading branch information
TheRealLyonic committed Jan 18, 2025
1 parent 6689fc0 commit b7aec35
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Nautilus/Utility/MaterialUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,14 @@ public static void ApplyGameMaterials(GameObject customPrefab, GameObject baseGa
foreach (var baseGameMat in baseGameRenderer.materials)
{
string baseMatName = baseGameMat.name.ToLower();
string plainBaseMatName = "";

//Removes the (instance) portion of the mat name, if it's present.
if (baseMatName.Contains("(instance)"))
baseMatName = baseMatName.Substring(0, baseMatName.LastIndexOf('(') - 1);
plainBaseMatName = baseMatName.Substring(0, baseMatName.LastIndexOf('(') - 1);

if (newMaterialList[j].name.ToLower().Contains(baseMatName))
string customMatName = newMaterialList[j].name.ToLower();
if (customMatName.Equals(baseMatName) || customMatName.Equals(plainBaseMatName))
{
newMaterialList[j] = baseGameMat;

Expand Down

0 comments on commit b7aec35

Please sign in to comment.