mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-10 07:04:36 +00:00
Remove texture references from materials when deleted
This commit is contained in:
parent
63fdff7b5e
commit
169a260946
2 changed files with 26 additions and 1 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue