mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2024-12-29 18:55:06 +08:00
Fix material setter index (#1061)
* fix: error when Material Setter has an invalid index * feat: warn by color when Material Setter has an invalid index
This commit is contained in:
parent
9d48ae4f65
commit
580cb2bfe9
@ -78,7 +78,7 @@ namespace nadena.dev.modular_avatar.core.editor.ShapeChanger
|
||||
var idx = int.Parse(idx_s);
|
||||
if (idx < 0 || idx >= sharedMaterials.Length)
|
||||
{
|
||||
return $"Element {idx_s}: <???>";
|
||||
return $"<color=\"red\">Element {idx_s}: <???></color>";
|
||||
}
|
||||
else if (sharedMaterials[idx] == null)
|
||||
{
|
||||
@ -89,7 +89,20 @@ namespace nadena.dev.modular_avatar.core.editor.ShapeChanger
|
||||
return $"Element {idx_s}: {sharedMaterials[idx].name}";
|
||||
}
|
||||
};
|
||||
f_material_index_dropdown.formatSelectedValueCallback = idx_s => $"Element {idx_s}";
|
||||
f_material_index_dropdown.formatSelectedValueCallback = idx_s =>
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(idx_s)) return "";
|
||||
|
||||
var idx = int.Parse(idx_s);
|
||||
if (idx < 0 || idx >= sharedMaterials.Length)
|
||||
{
|
||||
return $"<color=\"red\">Element {idx_s}</color>";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"Element {idx_s}";
|
||||
}
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -171,7 +171,7 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
Enumerable.SequenceEqual))
|
||||
{
|
||||
var renderer = _computeContext.GetComponent<Renderer>(obj.Object.Get(setter));
|
||||
if (renderer == null || renderer.sharedMaterials.Length < obj.MaterialIndex) continue;
|
||||
if (renderer == null || renderer.sharedMaterials.Length <= obj.MaterialIndex) continue;
|
||||
|
||||
var key = new TargetProp
|
||||
{
|
||||
|
@ -129,7 +129,7 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
|
||||
foreach (var mat in _materials)
|
||||
{
|
||||
if (mat.Item1 <= mats.Length)
|
||||
if (mat.Item1 < mats.Length)
|
||||
{
|
||||
mats[mat.Item1] = mat.Item2;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user