| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- using UnityEngine;
- public class DebugLine : MonoBehaviour
- {
- LineRenderer lr;
- Vector3[] vs = new Vector3[100];
- Vector3[] vs1 = new Vector3[303];
- float startX = -6;
- float len = 12;
- static DebugLine ins;
- void Start()
- {
- ins = this;
- this.lr = this.GetComponent<LineRenderer>();
- for (int i = 0; i < ins.vs.Length; i++)
- {
- this.vs[i].x = startX + len * i / ins.vs.Length;
- }
- LineRenderer lr1 = this.transform.GetChild(0).GetComponent<LineRenderer>();
- for (int i = 0; i < ins.vs1.Length; i+=3)
- {
- this.vs1[i].x = this.vs1[i+1].x = this.vs1[i+2].x = startX + len * i / 3 / this.vs.Length;
- this.vs1[i+1].y = -0.3f;
- }
- lr1.SetPositions(this.vs1);
- }
- void OnDestroy()
- {
- if (ins == this) ins = null;
- }
- public static void show(float value)
- {
- if (ins != null) {
- for (int i = ins.vs.Length - 1; i > 0; i--)
- {
- ins.vs[i].y = ins.vs[i - 1].y;
- }
- ins.vs[0].y = value;
- ins.lr.SetPositions(ins.vs);
- }
- }
- public static void showSteady(float value)
- {
- if (ins != null) {
- Transform t = ins.transform.Find("SteadyLine");
- Vector3 p = t.localPosition;
- p.y = value;
- t.localPosition = p;
- }
- }
- }
|