detect materials dynamically
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
{
|
||||
"ID": "29a0b0c54b40eb3e6857ffb4c9cab71e",
|
||||
"TypeName": "Game.BrushMaterialList",
|
||||
"EngineBuild": 6224,
|
||||
"Data": {
|
||||
"materialAssets": [
|
||||
{
|
||||
"name": "common/slick",
|
||||
"asset": "c27c22ec429a17e827421e9a82ac79e4"
|
||||
},
|
||||
{
|
||||
"name": "dev/dev_128_gray",
|
||||
"asset": "cfe2d8d64700dc00dc2c5088ee028477"
|
||||
},
|
||||
{
|
||||
"name": "dev/dev_128_red",
|
||||
"asset": "a75d425f40ef7ba5df0fdb8d470e8a78"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -181,27 +181,15 @@ namespace Game
|
||||
|
||||
if (!oneMesh)
|
||||
{
|
||||
|
||||
Dictionary<string, MaterialBase> materials = new Dictionary<string, MaterialBase>();
|
||||
{
|
||||
BrushMaterialList brushMaterialList = Engine.GetCustomSettings("BrushMaterials")
|
||||
BrushMaterialList brushMaterialList = Engine.GetCustomSettings("BrushMaterialsLegacy")
|
||||
?.CreateInstance<BrushMaterialList>();
|
||||
if (brushMaterialList != null)
|
||||
{
|
||||
foreach (var m in brushMaterialList.materialAssets)
|
||||
materials.Add(m.name, m.asset);
|
||||
Console.Print("materials dictionary with " + materials.Count + " entries");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.Print("no materials dictionary found");
|
||||
}
|
||||
|
||||
BrushMaterialList brushMaterialList2 = Engine.GetCustomSettings("BrushMaterialsLegacy")
|
||||
?.CreateInstance<BrushMaterialList>();
|
||||
if (brushMaterialList2 != null)
|
||||
{
|
||||
foreach (var m in brushMaterialList2.materialAssets)
|
||||
materials.Add(m.name, m.asset);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,9 +226,18 @@ namespace Game
|
||||
|
||||
if (!materials.TryGetValue(textureName, out var brushMaterial))
|
||||
{
|
||||
Console.Print("Material '" + textureName + "' not found for brush");
|
||||
materials.Add(textureName, material);
|
||||
brushMaterial = material;
|
||||
var workDir = Directory.GetCurrentDirectory();
|
||||
var matBasePath = Path.Combine(workDir, "Content", "Materials");
|
||||
var assetPath = Path.Combine(matBasePath, textureName + ".flax");
|
||||
brushMaterial = Content.Load<MaterialBase>(assetPath);
|
||||
if (brushMaterial != null)
|
||||
materials.Add(textureName, brushMaterial);
|
||||
else
|
||||
{
|
||||
Console.Print("Material '" + textureName + "' not found for brush");
|
||||
materials.Add(textureName, material);
|
||||
brushMaterial = material;
|
||||
}
|
||||
}
|
||||
brushMaterials.Add(textureName, brushMaterial);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user