Skip to content

Commit

Permalink
fix(MergeToonLit): Always marked as dirty on editor open
Browse files Browse the repository at this point in the history
  • Loading branch information
anatawa12 committed Feb 4, 2023
1 parent db9530b commit 82ba212
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Editor/MergeToonLitMaterialEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,13 @@ public override void OnInspectorGUI()
}
}

private void OnChanged()
private void OnChanged() => OnChanged(true);

private void OnChanged(bool dirty)
{
_generatedPreviews = null;
var component = (MergeToonLitMaterial)target;
EditorUtility.SetDirty(component);
if (dirty) EditorUtility.SetDirty(component);
var usedIndices = new HashSet<int>(component.merges.SelectMany(x => x.source.Select(y => y.materialIndex)));
_candidateMaterials = _materials.Where(x => !usedIndices.Contains(x.index)).ToArray();
_candidateNames = new []{""}.Concat(_candidateMaterials.Select(x => x.mat.name)).ToArray();
Expand Down Expand Up @@ -193,7 +195,7 @@ private void OnEnable()
.Select((mat, index) => (mat, index))
.Where(x => x.mat.shader == Utils.ToonLitShader)
.ToArray();
OnChanged();
OnChanged(dirty: false);
}
}
}
Expand Down

0 comments on commit 82ba212

Please sign in to comment.