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

@@ -2,14 +2,13 @@
using UnityEngine;
namespace Cryville.Crtr.Components {
public abstract class SpriteBase : SkinComponent {
public abstract class SpriteBase : MeshBase {
public SpriteBase() {
SubmitProperty("bound", new op_set_bound(this));
SubmitProperty("transparent", new PropOp.Boolean(v => transparent = v));
SubmitProperty("pivot", new PropOp.Vector2(v => Pivot = v));
SubmitProperty("scale", new PropOp.Vector2(v => Scale = v));
SubmitProperty("ui", new PropOp.Boolean(v => UI = v));
SubmitProperty("zindex", new PropOp.Integer(v => ZIndex = (short)v));
}
#pragma warning disable IDE1006
@@ -27,8 +26,6 @@ namespace Cryville.Crtr.Components {
}
#pragma warning restore IDE1006
protected MeshWrapper mesh = new MeshWrapper();
protected override void OnDestroy() {
mesh.Destroy();
}
@@ -82,21 +79,6 @@ namespace Cryville.Crtr.Components {
if (da.x != 0) _scale.x = dp.x / da.x;
if (da.y != 0) _scale.y = dp.z / da.y;
}
short _zindex;
public short ZIndex {
get {
return _zindex;
}
set {
_zindex = value;
UpdateZIndex();
}
}
protected void UpdateZIndex() {
if (!mesh.Initialized) return;
mesh.Renderer.sortingOrder = _zindex;
}
static readonly Quaternion uirot
= Quaternion.Euler(new Vector3(-90, 0, 0));