Add component linesec
.
This commit is contained in:
@@ -44,7 +44,7 @@ namespace Cryville.Crtr.Components {
|
||||
UpdateColor();
|
||||
}
|
||||
}
|
||||
protected void UpdateColor() {
|
||||
protected virtual void UpdateColor() {
|
||||
if (!mesh.Initialized) return;
|
||||
foreach (var mat in materials) {
|
||||
mat.color = _color;
|
||||
|
@@ -5,8 +5,38 @@ namespace Cryville.Crtr.Components {
|
||||
public class TrackLine : SectionalGameObject {
|
||||
readonly List<Vector3> vertices = new List<Vector3>();
|
||||
|
||||
LineRenderer lineRenderer;
|
||||
|
||||
public TrackLine() {
|
||||
SubmitProperty("width", new PropOp.Float(v => Width = v));
|
||||
}
|
||||
|
||||
private float m_width;
|
||||
public float Width {
|
||||
get { return m_width; }
|
||||
set {
|
||||
m_width = value;
|
||||
if (lineRenderer != null) {
|
||||
lineRenderer.startWidth = value;
|
||||
lineRenderer.endWidth = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Init() {
|
||||
base.Init();
|
||||
lineRenderer = gameObject.AddComponent<LineRenderer>();
|
||||
lineRenderer.materials = materials = new Material[] { MeshWrapper.NewMaterial() };
|
||||
Width = Width;
|
||||
UpdateColor();
|
||||
}
|
||||
|
||||
protected override void UpdateColor() {
|
||||
base.UpdateColor();
|
||||
if (lineRenderer != null) {
|
||||
lineRenderer.startColor = Color;
|
||||
lineRenderer.endColor = Color;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void AppendPointInternal(Vector3 p, Quaternion r) {
|
||||
@@ -14,13 +44,12 @@ namespace Cryville.Crtr.Components {
|
||||
}
|
||||
|
||||
public override void Seal() {
|
||||
var r = GetComponent<LineRenderer>();
|
||||
#if UNITY_5_6_OR_NEWER
|
||||
r.positionCount = vertices.Count;
|
||||
lineRenderer.positionCount = vertices.Count;
|
||||
#else
|
||||
r.SetVertexCount(vertices.Count);
|
||||
lineRenderer.SetVertexCount(vertices.Count);
|
||||
#endif
|
||||
for (int i = 0; i < vertices.Count; i++) r.SetPosition(i, vertices[i]);
|
||||
for (int i = 0; i < vertices.Count; i++) lineRenderer.SetPosition(i, vertices[i]);
|
||||
}
|
||||
|
||||
public override void Reset() {
|
||||
|
@@ -20,6 +20,7 @@ namespace Cryville.Crtr {
|
||||
if (loaded) return;
|
||||
Components.Add("anim", typeof(SkinAnimation));
|
||||
Components.Add("image", typeof(SpritePlane));
|
||||
Components.Add("linesec", typeof(TrackLine));
|
||||
Components.Add("mesh", typeof(MeshBase));
|
||||
Components.Add("polysec", typeof(PolygonSGO));
|
||||
Components.Add("rect", typeof(SpriteRect));
|
||||
|
Reference in New Issue
Block a user