Loading files
using Leap.Unity.Attributes;
using System.Collections.Generic;
using UnityEngine;
namespace Leap.Unity.Apps.Paint4.LineDrawing {
[RequireComponent(typeof(LineRenderer))]
[ExecuteInEditMode]
public class LineRendererController : MonoBehaviour {
private LineRenderer _lineRenderer;
void Start() {
_lineRenderer = GetComponent<LineRenderer>();
}
private static List<Vector3> s_positionCache = new List<Vector3>();
public void Refresh() {
s_positionCache.Clear();
foreach (var lineAnchor in GetComponentsInChildren<LineAnchor>()) {
s_positionCache.Add(lineAnchor.transform.position);
}
_lineRenderer.positionCount = s_positionCache.Count;
_lineRenderer.SetPositions(s_positionCache.ToArray());
}
public void AddLineAnchor(Vector3 position) {
GameObject lineAnchorObj = new GameObject("Line Anchor");
lineAnchorObj.transform.position = position;
lineAnchorObj.transform.parent = this.transform;
lineAnchorObj.AddComponent<LineAnchor>();
}
}
}743f6b6f9This file is pinned to the selected release. Download the original to open it in your design tool.