Remove texture references from materials when deleted

This commit is contained in:
KillzXGaming 2019-10-18 17:18:35 -04:00
parent 63fdff7b5e
commit 169a260946
2 changed files with 26 additions and 1 deletions

View file

@ -349,8 +349,10 @@ namespace LayoutBXLYT.Cafe
public override void RemoveTexture(string name)
{
if (!TextureList.Textures.Contains(name))
if (TextureList.Textures.Contains(name))
TextureList.Textures.Remove(name);
RemoveTextureReferences(name);
}
public override short AddMaterial(BxlytMaterial material)

View file

@ -1689,6 +1689,12 @@ namespace LayoutBXLYT
return new BxlytMaterial();
}
public void RemoveTextureReferences(string texture)
{
foreach (var mat in GetMaterials())
mat.TryRemoveTexture(texture);
}
public BxlytMaterial SearchMaterial(string name)
{
var materials = GetMaterials();
@ -1828,6 +1834,23 @@ namespace LayoutBXLYT
[Browsable(false)]
public TreeNodeCustom NodeWrapper;
public bool TryRemoveTexture(string name)
{
int removeIndex = -1;
for (int i = 0; i < TextureMaps?.Length; i++)
{
if (TextureMaps[i].Name == name)
removeIndex = i;
}
if (removeIndex != -1)
{
TextureMaps.RemoveAt(removeIndex);
return true;
}
return false;
}
public void RemoveNodeWrapper()
{
if (NodeWrapper.Parent != null)