Fix z-index. Pull up z-index to MeshBase.

This commit is contained in:
2022-11-18 09:58:01 +08:00
parent 79bfd6764c
commit bf942cbe45
5 changed files with 42 additions and 21 deletions

View File

@@ -0,0 +1,28 @@
using System;
namespace Cryville.Crtr.Components {
public abstract class MeshBase : SkinComponent {
public MeshBase() {
SubmitProperty("zindex", new PropOp.Integer(v => ZIndex = (short)v));
}
protected MeshWrapper mesh = new MeshWrapper();
short _zindex;
public short ZIndex {
get {
return _zindex;
}
set {
if (value < 0 || value > 5000)
throw new ArgumentOutOfRangeException("value", "Z-index must be in [0..5000]");
_zindex = value;
UpdateZIndex();
}
}
protected void UpdateZIndex() {
if (!mesh.Initialized) return;
mesh.Renderer.material.renderQueue = _zindex;
}
}
}