mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-01-01 12:15:05 +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);
|
var idx = int.Parse(idx_s);
|
||||||
if (idx < 0 || idx >= sharedMaterials.Length)
|
if (idx < 0 || idx >= sharedMaterials.Length)
|
||||||
{
|
{
|
||||||
return $"Element {idx_s}: <???>";
|
return $"<color=\"red\">Element {idx_s}: <???></color>";
|
||||||
}
|
}
|
||||||
else if (sharedMaterials[idx] == null)
|
else if (sharedMaterials[idx] == null)
|
||||||
{
|
{
|
||||||
@ -89,7 +89,20 @@ namespace nadena.dev.modular_avatar.core.editor.ShapeChanger
|
|||||||
return $"Element {idx_s}: {sharedMaterials[idx].name}";
|
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
|
else
|
||||||
{
|
{
|
||||||
|
@ -171,7 +171,7 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
Enumerable.SequenceEqual))
|
Enumerable.SequenceEqual))
|
||||||
{
|
{
|
||||||
var renderer = _computeContext.GetComponent<Renderer>(obj.Object.Get(setter));
|
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
|
var key = new TargetProp
|
||||||
{
|
{
|
||||||
|
@ -129,7 +129,7 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
|
|
||||||
foreach (var mat in _materials)
|
foreach (var mat in _materials)
|
||||||
{
|
{
|
||||||
if (mat.Item1 <= mats.Length)
|
if (mat.Item1 < mats.Length)
|
||||||
{
|
{
|
||||||
mats[mat.Item1] = mat.Item2;
|
mats[mat.Item1] = mat.Item2;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user